Re: Re: postgres_fdw: Use COPY to speed up batch inserts
| От | Dewei Dai |
|---|---|
| Тема | Re: Re: postgres_fdw: Use COPY to speed up batch inserts |
| Дата | |
| Msg-id | 202601032045434521683@163.com обсуждение исходный текст |
| Ответ на | postgres_fdw: Use COPY to speed up batch inserts ("Matheus Alcantara" <matheusssilv97@gmail.com>) |
| Ответы |
Re: postgres_fdw: Use COPY to speed up batch inserts
|
| Список | pgsql-hackers |
Hi Matheus,
I just reviewed the v8 patch and got a few comments:
1 - in function `execute_foreign_modify_using_copy`
The `res` object obtained from the first call to `pgfdw_get_result`
is not freed, maybe you can use `PQclear` to release it
2 - in function `execute_foreign_modify_using_copy`
After using `copy_data`,it appears it can be released by
calling `destroyStringInfo`.
3 - in function `convert_slot_to_copy_text`
The value returned by the OutputFunctionCall function can be
freed by calling pfree
4 - in function `execute_foreign_modify_using_copy`
```Send initial COPY data if the buffer reach the limit to avoid large
```
Typo: reach -> reaches
Best regards,
Dewei Dai
daidewei1970@163.com
From: Matheus AlcantaraDate: 2026-01-03 04:33Subject: Re: postgres_fdw: Use COPY to speed up batch insertsOn Fri Jan 2, 2026 at 5:15 PM -03, Masahiko Sawada wrote:> +> + /*> + * Set batch_with_copy_threshold from foreign server/table options. We do> + * this outside of create_foreign_modify() because we only want to use> + * COPY as a remote SQL when a COPY FROM on a foreign table is executed or> + * an insert is being performed on a table partition. In both cases the> + * BeginForeignInsert fdw routine is called.> + */> + fmstate->batch_with_copy_threshold = get_batch_with_copy_threshold(rel);>> Does it mean that we could end up using the COPY method not only when> executing COPY FROM but also when executing INSERT with tuple> routings? If so, how does the EXPLAIN command show the remote SQL?>It meas that we could also use the COPY method to insert rows into aspecific table partition that is a foreign table.Let's say that an user execute an INSERT INTO on a partitioned tablethat has partitions that are postgres_fdw tables, with this patch wecould use the COPY method to insert the rows on these partitions. Onthis scenario we would not have issue with EXPLAIN output becausecurrently we do not show the remote SQL being executed on each partitionthat is involved on the INSERT statement.If an user execute an INSERT directly into a postgres_fdw table we willuse the normal INSERT statement as we use today.Thanks for taking a look at this.--Matheus AlcantaraEDB: https://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: