public inbox for [email protected]  
help / color / mirror / Atom feed
From: Masahiko Sawada <[email protected]>
To: Amit Kapila <[email protected]>
Cc: Peter Smith <[email protected]>
Cc: Jan Wieck <[email protected]>
Cc: [email protected]
Subject: Re: Initial COPY of Logical Replication is too slow
Date: Tue, 31 Mar 2026 10:28:11 -0700
Message-ID: <CAD21AoCLvb37vW0pE2eG0=aD0ifTTX-ruBJB8QHYbcMynUQPdQ@mail.gmail.com> (raw)
In-Reply-To: <CAA4eK1K+rumWz=mHDLVVCig-i_cWWSzwDE1eMySq0WYc7_ve+Q@mail.gmail.com>
References: <CAB-JLwbBFNuASyEnZWP0Tck9uNkthBZqi6WoXNevUT6+mV8XmA@mail.gmail.com>
	<CAD21AoA6i2ui8FMZeuU_KxX4t-fM8G==zTW2Dp6-goujttrpew@mail.gmail.com>
	<CAB-JLwZpp=7c9_r0beWWJxRh2BS_2Vvth8UDv7H57DBeaqggVg@mail.gmail.com>
	<CAD21AoDT3sL2COprsRumM9zEpL1Bk5VWboK4V2mRnjGua8xfeA@mail.gmail.com>
	<CAD21AoDQM62GOtaTzD_CVMSsFhv6o9c0Au1dSM1QuxeKFkWAKw@mail.gmail.com>
	<CAD21AoCz7HjEr3oeb=haK31YHxHZLcvD_wx_a-+xLPKywq++3A@mail.gmail.com>
	<TY4PR01MB16907733B75A99117F013AFCA947FA@TY4PR01MB16907.jpnprd01.prod.outlook.com>
	<CAD21AoA9YgiY1rVKMPZwB00WU_G4UfzoawY=7hyd7hpvBPcK6w@mail.gmail.com>
	<CAA4eK1KoSi60dtakJzn0MxNnHF1Yf4indSAffTjJxQG_31jsgQ@mail.gmail.com>
	<CAD21AoB4B3MOxJ7-v9YLjV5fTOtaLRUhX3jN3kqhEi7D7-uY4A@mail.gmail.com>
	<[email protected]>
	<CAD21AoCmHpKrNg9D3mcOA973CZ5N_dBLxb8pERpSxEeRLSQxpA@mail.gmail.com>
	<CAD21AoAEVyxwn_bMWHvcU-Gcz3aUVjAtMbdgfoJ8MZNiLLEh0g@mail.gmail.com>
	<CAA4eK1Jkouj=w+PHzMB6v890ES3QOLf=cUTvZmGFr-WMQW2OnA@mail.gmail.com>
	<CAD21AoB4_n7+s=uM9apX1JVtvGvgM8ismAx_uMxvDmUXfQULsw@mail.gmail.com>
	<CAD21AoBJcxRcaWQot302diaxoDcsnezRhnZa7p8UrPh5AGNeHQ@mail.gmail.com>
	<CAHut+PuSkabUB8H_hcwQz=BX5TWEj-8Ba+CP_PX78zN1fkhtKA@mail.gmail.com>
	<CAA4eK1K+rumWz=mHDLVVCig-i_cWWSzwDE1eMySq0WYc7_ve+Q@mail.gmail.com>

On Tue, Mar 31, 2026 at 2:36 AM Amit Kapila <[email protected]> wrote:
>
> On Wed, Mar 25, 2026 at 2:19 PM Peter Smith <[email protected]> wrote:
> >
> > 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.
> >
>
> I can't say exactly why, but I find it difficult to read this
> function. So, I share your concerns about the code of this function.
> Because of its complexity it is difficult to ascertain that the
> functionality is correct or we missed something. Also, considering it
> is correct today, in its current form, it may become difficult to
> enhance it in future.

Okay, I'll refactor that function.

>
> One more comment on latest patch:
> *
> +static Datum
> +pg_get_publication_tables(FunctionCallInfo fcinfo, ArrayType *pubnames,
> +                          Oid target_relid, bool filter_by_relid,
>
> Why do we need filter_by_relid as a separate parameter? Isn't the
> valid value of target_relid the same? If so, can't we use target_relid
> for the required checks?

If we don't have filter_by_relid, we would end up not filtering
anything if users pass 0 (InvalidOid) as the target_relid to the new
pg_get_publication_tables(). This is the same as the behavior of the
existing pg_get_publication_tables(), so I'm concerned that it could
be confusing that the function behaves the same even though passing
different arguments . We can check whether the given target_relid is
valid in pg_get_publication_b() but we would end up checking it
multiple times unnecessarily.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com





view thread (51+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Initial COPY of Logical Replication is too slow
  In-Reply-To: <CAD21AoCLvb37vW0pE2eG0=aD0ifTTX-ruBJB8QHYbcMynUQPdQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox