RE: POC: postgres_fdw insert batching - Mailing list pgsql-hackers

From tsunakawa.takay@fujitsu.com
Subject RE: POC: postgres_fdw insert batching
Date
Msg-id TYAPR01MB29907E89506E094B0627B416FEE70@TYAPR01MB2990.jpnprd01.prod.outlook.com
Whole thread Raw
In response to RE: POC: postgres_fdw insert batching  (Tim.Colles@ed.ac.uk)
List pgsql-hackers
From: timc@corona.is.ed.ac.uk <timc@corona.is.ed.ac.uk> On Behalf Of
> Does this patch affect trigger semantics on the base table?
>
> At the moment when I insert 1000 rows into a postgres_fdw table using a
> single insert statement (e.g. INSERT INTO fdw_foo SELECT ... FROM bar) I
> naively expect a "statement level" trigger on the base table to trigger
> once. But this is not the case. The postgres_fdw implements this
> operation as 1000 separate insert statements on the base table, so the
> trigger happens 1000 times instead of once. Hence there is no
> distinction between using a statement level and a row level trigger on
> the base table in this context.
>
> So would this patch change the behaviour so only 10 separate insert
> statements (each of 100 rows) would be made against the base table?
> If so thats useful as it means improving performance using statement
> level triggers becomes possible. But it would also result in more
> obscure semantics and might break user processes dependent on the
> existing behaviour after the patch is applied.

Yes, the times the statement trigger defined on the base (remote) table will be reduced, as you said.


> BTW is this subtlety documented, I haven't found anything but happy
> to be proved wrong?

Unfortunately, there doesn't seem to be any description on triggers on base tables.  For example, if the local foreign
tablehas an AFTER ROW trigger and its remote base table has a BEFORE ROW trigger that modifies the input record, it
seemsthat the AFTER ROW trigger doesn't see the modified record. 


Regards
Takayuki Tsunakawa




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Avoiding useless SHA256 initialization with backup manifests, breaking base backups with FIPS
Next
From: Craig Ringer
Date:
Subject: Re: Add docs stub for recovery.conf