RE: Initial COPY of Logical Replication is too slow - Mailing list pgsql-hackers

From Hayato Kuroda (Fujitsu)
Subject RE: Initial COPY of Logical Replication is too slow
Date
Msg-id OS9PR01MB1214911ABEEB9C5AEED005B93F553A@OS9PR01MB12149.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Initial COPY of Logical Replication is too slow  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Initial COPY of Logical Replication is too slow
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Eliminating SPI / SQL from some RI triggers - take 3
Next
From: Peter Eisentraut
Date:
Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber