Re: Delay locking partitions during INSERT and UPDATE - Mailing list pgsql-hackers

From John Naylor
Subject Re: Delay locking partitions during INSERT and UPDATE
Date
Msg-id CAJVSVGVz2Ln3o8hq7rWTbjn1JCM3FGiLFKE4ofAhqGuh89m8kA@mail.gmail.com
Whole thread Raw
In response to Delay locking partitions during INSERT and UPDATE  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: Delay locking partitions during INSERT and UPDATE  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Re: Delay locking partitions during INSERT and UPDATE  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
On 11/22/18, David Rowley <david.rowley@2ndquadrant.com> wrote:
> If required, such operations could LOCK TABLE the top partitioned
> table to block the DML operation. There's already a risk of similar
> deadlocks from such operations done on multiple separate tables when
> the order they're done is not the same as the order the tables are
> written in a query, although, in that case, the window for the
> deadlock is likely to be much smaller.

Is this something that would need documentation anywhere?

> With this done, the performance of an INSERT into a 10k partition
> partitioned table looks like:
>
> Setup:
> create table hashp (a int) partition by hash(a);
> select 'create table hashp'||x::Text || ' partition of hashp for
> values with (modulus 10000, remainder '||x::text||');' from
> generate_Series(0,9999) x;
> \gexec
>
> hashp_insert.sql:
> \set p_a random(1,1000)
> insert into hashp values(:p_a);
>
> Results:
> $ psql -c "truncate hashp;" postgres && pgbench -n -f hashp_insert.sql
> -M prepared -c 4 -j 4 -T 60 postgres

I used a similar test, but with unlogged tables, and "-c 2", and got:

normal table: 32000tps
10k partitions / master: 82tps
10k partitions / patch: 7000tps

So far I haven't gotten quite as good performance as you and Tomas,
although it's still a ~85x improvement.

-John Naylor


pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: jsonpath
Next
From: Tom Lane
Date:
Subject: Re: Fixing findDependentObjects()'s dependency on scan order (regressions in DROP diagnostic messages)