Re: [POC] Fast COPY FROM command for the table with foreign partitions
Andrei Lepikhov <a.lepikhov@postgrespro.ru>
From: "Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru>
To: Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>,
Etsuro Fujita <etsuro.fujita@gmail.com>,
PostgreSQL-Dev <pgsql-hackers@postgresql.org>
Date: 2020-07-03T05:15:46Z
Lists: pgsql-hackers
On 6/22/20 5:11 PM, Ashutosh Bapat wrote: > <a.lepikhov@postgrespro.ru <mailto:a.lepikhov@postgrespro.ru>> wrote: > It looks like we call BeginForeignInsert and EndForeignInsert even > though actual copy is performed using BeginForeignCopy, ExecForeignCopy > and EndForeignCopy. BeginForeignInsert constructs the INSERT query which > looks unnecessary. Also some of the other PgFdwModifyState members are > initialized unnecessarily. It also gives an impression that we are using > INSERT underneath the copy. Instead a better way would be to > call BeginForeignCopy instead of BeginForeignInsert and EndForeignCopy > instead of EndForeignInsert, if we are going to use COPY protocol to > copy data to the foreign server. Corresponding postgres_fdw > implementations need to change in order to do that. > I did not answer for a long time, because of waiting for the results of the discussion on Tomas approach to bulk INSERT/UPDATE/DELETE. It seems more general. I can move the query construction into the first execution of INSERT or COPY operation. But another changes seems more invasive because BeginForeignInsert/EndForeignInsert are used in the execPartition.c module. We will need to pass copy/insert state of operation into ExecFindPartition() and ExecCleanupTupleRouting(). -- regards, Andrey Lepikhov Postgres Professional
Commits
-
Allow batch insertion during COPY into a foreign table.
- 97da48246d34 16.0 landed
-
postgres_fdw: Disable batch insertion when there are WCO constraints.
- 82593b9a3d5f 16.0 cited
-
Enforce foreign key correctly during cross-partition updates
- ba9a7e392171 15.0 cited
-
Fix permission checks on constraint violation errors on partitions.
- 6214e2b22804 14.0 cited
-
Fix compilation of uuid-ossp
- 525e60b74299 14.0 cited