1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Use "COPY table TO" for partitioned tables in initial table synchronization.

Commit 4bea91f added support for "COPY table TO" with partitioned
tables. This commit enhances initial table synchronization in logical
replication to use "COPY table TO" for partitioned tables if possible,
instead of "COPY (SELECT ...) TO" variant, improving performance.

Author: Ajin Cherian <itsajin@gmail.com>
Discussion: https://postgr.es/m/CAFPTHDY=w+xmEof=yyjhbDzaLxhBkoBzKcksEofXcT6EcjMbtQ@mail.gmail.com
This commit is contained in:
Masahiko Sawada
2025-11-20 14:50:27 -08:00
parent 1e14edcea5
commit 266543a620

View File

@@ -1068,8 +1068,9 @@ copy_table(Relation rel)
/* Start copy on the publisher. */ /* Start copy on the publisher. */
initStringInfo(&cmd); initStringInfo(&cmd);
/* Regular table with no row filter or generated columns */ /* Regular or partitioned table with no row filter or generated columns */
if (lrel.relkind == RELKIND_RELATION && qual == NIL && !gencol_published) if ((lrel.relkind == RELKIND_RELATION || lrel.relkind == RELKIND_PARTITIONED_TABLE)
&& qual == NIL && !gencol_published)
{ {
appendStringInfo(&cmd, "COPY %s", appendStringInfo(&cmd, "COPY %s",
quote_qualified_identifier(lrel.nspname, lrel.relname)); quote_qualified_identifier(lrel.nspname, lrel.relname));