On 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 a specific table partition that is a foreign table.
Let's say that an user execute an INSERT INTO on a partitioned table that has partitions that are postgres_fdw tables, with this patch we could use the COPY method to insert the rows on these partitions. On this scenario we would not have issue with EXPLAIN output because currently we do not show the remote SQL being executed on each partition that is involved on the INSERT statement. If an user execute an INSERT directly into a postgres_fdw table we will use the normal INSERT statement as we use today. Thanks for taking a look at this. -- Matheus Alcantara EDB: https://www.enterprisedb.com
