RE: Avoid CommandCounterIncrement in RI trigger when INSERT INTO referencing table - Mailing list pgsql-hackers

From houzj.fnst@fujitsu.com
Subject RE: Avoid CommandCounterIncrement in RI trigger when INSERT INTO referencing table
Date
Msg-id OS0PR01MB57166504AE683F116348B1A294659@OS0PR01MB5716.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Avoid CommandCounterIncrement in RI trigger when INSERT INTO referencing table  (Greg Nancarrow <gregn4422@gmail.com>)
List pgsql-hackers
Hi,

Thanks for the review.

> I noticed some things on the first scan through:
> 
> Patch 0001:
> 1) Tidy up the comments a bit:
> 
> Suggest the following update to part of the comments:

Changed.

> Patch 0002:
> 1) The new max_parallel_hazard_context member "pk_rels" is not being 
> set (to
> NIL) in the is_parallel_safe() function, so it will have a junk value 
> in that case - though it does look like nothing could reference it 
> then (but the issue may be detected by a Valgrind build, as performed by the buildfarm).

Changed.

> 2) Few things to tidy up the patch comments:

Changed.

> 3) In target_rel_trigger_max_parallel_hazard(), you have added a 
> variable declaration "int trigtype;" after code, instead of before:

Changed.

Attaching new version patch with these changes.

Also attaching the simple performance test results (insert into table with foreign key):
postgres=# explain (analyze, verbose) insert into fk select a,func_xxx() from data where a%2=0 or a%3 = 0;
  workers  | serial insert + parallel select | parallel insert | performace gain
-----------+---------------------------------+-----------------+--------
2 workers | 85512.153ms                     | 61384.957ms     | 29%
4 workers | 85436.957ms                     | 39335.797ms     | 54%

-------------data prepare-----------------------------
create table pk(a int primary key,b int);
create table fk(a int references pk,b int);
create table data(a int, b int);
insert into data select * from generate_series(1,10000000,1) t;
 insert into pk select generate_series(1,10000000,1);
------------------------------------------------

Best regards,
houzj

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Permission failures with WAL files in 13~ on Windows
Next
From: torikoshia
Date:
Subject: Re: Get memory contexts of an arbitrary backend process