public inbox for [email protected]  
help / color / mirror / Atom feed
From: Hayato Kuroda (Fujitsu) <[email protected]>
To: 'Masahiko Sawada' <[email protected]>
To: Zhijie Hou (Fujitsu) <[email protected]>
Cc: Amit Kapila <[email protected]>
Cc: Jan Wieck <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: Initial COPY of Logical Replication is too slow
Date: Tue, 31 Mar 2026 11:39:01 +0000
Message-ID: <OS9PR01MB1214911ABEEB9C5AEED005B93F553A@OS9PR01MB12149.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAD21AoAfXAUhLzo4tHM9ssA4SGGSZoZPwrxf5mcp9k8zJ8zr5g@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>
	<CAA4eK1+ATysKLptbK+x8ygB7OAa=LHw3XTqMxKjVMsTRfdbRzQ@mail.gmail.com>
	<CAD21AoCLodVegaB=HDfxFMe8s9TMUxj+okznt6yjizN+5TVOfA@mail.gmail.com>
	<OS9PR01MB1214992889432F8A936AAAA32F557A@OS9PR01MB12149.jpnprd01.prod.outlook.com>
	<CAA4eK1LR4GaoqD_pt-KZrroCTaQZ3HCT3BiU1qGTRQLWpNRHmg@mail.gmail.com>
	<CAD21AoCzACbf=FwZ11v6uLHAPDC_+zSDwmj7cpabOkDbTAKa8w@mail.gmail.com>
	<TY4PR01MB169072EB113D17B71CF1F97FA9452A@TY4PR01MB16907.jpnprd01.prod.outlook.com>
	<CAD21AoAfXAUhLzo4tHM9ssA4SGGSZoZPwrxf5mcp9k8zJ8zr5g@mail.gmail.com>

Dear Sawada-san,

Thanks for updating the patch! Few comments.

01.
```
+/*
+ * Similar to is_publishable_calss() but checks whether the given OID
+ * is a publishable "table" or not.
+ */
+static bool
+is_publishable_table(Oid tableoid)
```

s/is_publishable_calss/is_publishable_class/.

02.
```
+       ReleaseSysCache(tuple);
+       return true;
```

Is it correct? I expected to return false here.

03.
```
+               /*
+                * Preliminary check if the specified table can be published in the
+                * first place. If not, we can return early without checking the given
+                * publications and the table.
+                */
+               if (filter_by_relid && !is_publishable_table(target_relid))
+                       SRF_RETURN_DONE(funcctx);
```

I think we must switch to the old context.

04.
```
+CREATE PUBLICATION pub_all_except FOR ALL TABLES EXCEPT TABLE (tbl_parent, gpt_test_sch.tbl_sch) WITH (publish_via_partition_root = false);
+CREATE PUBLICATION pub_all_except_no_viaroot FOR ALL TABLES EXCEPT TABLE (tbl_parent, gpt_test_sch.tbl_sch) WITH (publish_via_partition_root = true);
```

It needs to be rebased due to 5984ea86.

05.
```
CREATE VIEW pg_publication_tables AS
    SELECT
        P.pubname AS pubname,
        N.nspname AS schemaname,
        C.relname AS tablename,
        ( SELECT array_agg(a.attname ORDER BY a.attnum)
          FROM pg_attribute a
          WHERE a.attrelid = GPT.relid AND
                a.attnum = ANY(GPT.attrs)
        ) AS attnames,
        pg_get_expr(GPT.qual, GPT.relid) AS rowfilter
     FROM pg_publication P,
          LATERAL pg_get_publication_tables(P.pubname) GPT,
          pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
     WHERE C.oid = GPT.relid;
```

Can we use the new API of pg_get_publication_tables() here? Below change can pass
tests on my env.

```
-         LATERAL pg_get_publication_tables(P.pubname) GPT,
-         pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
-    WHERE C.oid = GPT.relid;
+         pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace),
+         LATERAL pg_get_publication_tables(ARRAY[P.pubname], C.oid) GPT;
```

Best regards,
Hayato Kuroda
FUJITSU LIMITED



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], [email protected]
  Subject: RE: Initial COPY of Logical Replication is too slow
  In-Reply-To: <OS9PR01MB1214911ABEEB9C5AEED005B93F553A@OS9PR01MB12149.jpnprd01.prod.outlook.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