Re: Initial COPY of Logical Replication is too slow

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Initial COPY of Logical Replication is too slow
Date: 2026-03-25 08:48:32
Message-ID: CAHut+PuSkabUB8H_hcwQz=BX5TWEj-8Ba+CP_PX78zN1fkhtKA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Swada-San. Here are some minor review comments for v4-0001/2 combined.

======
src/backend/catalog/pg_publication.c

is_table_publishable_in_publication:

1.
This function logic has a format like

if (cond)
{
...
return;
}

if (cond2)
{
...
return;
}

etc.

There are many return points, and most of those "if" blocks cannot
fall through (they return).

I found it slightly difficult to read the code because I kept having
to think, "OK, if we reached here, it means pubviaroot must be false,"
or "OK, if we reached this far, then puballtables must be false, and
pubviaroot must be false," etc.

Maybe a few more if/else, or a few Assert() can make it easier to
understand how we reached points deeper in this function.

~~~

pg_get_publication_tables:

2.
Several code comments appear to wrap prematurely. It looks as if
pg_indent was run when the code was different to what it is now.

~~~

pg_get_publication_tables_b:

3.
/* Get the information of the specified table in the given publication */
- return pg_get_publication_tables(fcinfo, NULL, PG_GETARG_TEXT_P(0),
PG_GETARG_OID(1));
+ return pg_get_publication_tables(fcinfo, PG_GETARG_ARRAYTYPE_P(0), relid);

Should that comment be plural now, the same as the other one?
/publication/publications/

======
src/include/catalog/pg_proc.dat

4.
proargnames => '{pubname,pubid,relid,attrs,qual}',
prosrc => 'pg_get_publication_tables_a' },

Shouldn’t the original function proargnames here also be calling the
first arg 'pubnames' instead of 'pubname'

======
src/test/regress/sql/publication.sql

5.
-- Test pg_get_publication_tables(text, oid) function

Should that comment now say text[] instead of text?

~~~

6.
Many of those tests have a "good result" test and a "no result" test
for each publication. It might be better if they were consistently in
the same order (eg, good then none, or none then good).

~~~

7.
Only 3 of the tests are passing multiple publications. Maybe those can
be separated from the others (e.g. put last, just to keep all the ones
that look alike together).

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-03-25 08:54:00 Make \d tablename fast again, regression introduced by 85b7efa1cdd
Previous Message Peter Eisentraut 2026-03-25 08:41:42 Re: SQL Property Graph Queries (SQL/PGQ)