Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7en7-005ZDQ-2D for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 19:30:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7en5-00Cpjm-0j for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 19:30:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7en4-00Cpjd-2g for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 19:30:19 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7en3-000000021Gr-1GyD for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 19:30:18 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5a2beddab48so1029477e87.1 for ; Tue, 31 Mar 2026 12:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774985416; cv=none; d=google.com; s=arc-20240605; b=S9Qr6pFwTb9r+MdNjUG2Aus+TigO49DYp2WedSUPoQos5Tuy6/oDIh6kg6YyOELEgQ 03F/kteG3JhY9jMocZ9CtuyeOU2AitUb6dL/8B6UY9f6NCJxxw/Uxi6Cx5lg/UWyVnH6 tEKIGFHtM/xdv9qjwrjkbsVmFkc1AtwnNd9LyMGZ/WwsZduxxUDRknj6Z5PmDpH2O7JD jmttn4Tkiau+8AkSIm9kqBy+NavvFdYuZQj1dPIyR2xOcqM9LKT4YpOh3+tTKSrJ8cEu aMDC7Bhjscvg1HuvplM3wZ8aaCNITC6DBJgUSR4rueUyHPv3Ib5R4bEXuskzoG6ge8Ab uPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Gn1SMrRR/dmqtAnUU6hpbVG4mhbTVqdvALXgfOVauKI=; fh=TfuRNIkhgXe6swDaFrAIsJnE5zjCOhWjFvuw6p8pW/s=; b=jVeJsU8vTdH3gigqAYulUS3rSEt3uDiK8nDGjqDLhQ1xahMonmXO/28x6Q1BB0u8DH wl1ONNBLXz7cp85gijP08Z4QvOerHr2d9WifxDEX0q/eIbxzrTY2+RXlfh1opMq1zZ0L kmEtkJwejf6FUry3pG4Y61nKN1jeMLBS/M5ZAcko7USYDQJvKd4nC2Y+E8BWdCbq1TFK BkGTMWvti4cV7kfT6UrZc3J7tpnLDYd3g/2SgV3dvhMorXO359b7Qhw1+Xa92qnao1K4 W8uY+OgWy48Hdi2EvnvA5Bi5cmAQnxf340BsyjTVclXimwKxYSEP0Ij7B1/Fe4UX2N14 nbiA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774985416; x=1775590216; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Gn1SMrRR/dmqtAnUU6hpbVG4mhbTVqdvALXgfOVauKI=; b=qf28eb/YW9aeMcNux5iJNFEjoeIKEE7lui+61lGBeTC5lEMIMUG8MBmpXiEHtCDXPv iGyR6Rb3HNk69mqkFvFDIo4jX4b194wTPs96NhKASsCvifSAPi9+ySGXbc5bgxw810fH XaojPvE6t0T4PtEebzpPk5+rElfEm7cjRRJ0tzBsKPwdY+1hnpIuX7T5KVmCjkhA0GeZ GJrd4pfPe3yjQud0zcdUqcTju50aa0nju8V+H9/OIldVBKmRyViGAtlX8/7sKzXCgTtf KN6ZskVGxUXARckMyGmP9CYzZTzwWPJI2GdAAdreaOC6qzMDRxmMcAN8mWgFHSuS4fyo BIuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774985416; x=1775590216; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Gn1SMrRR/dmqtAnUU6hpbVG4mhbTVqdvALXgfOVauKI=; b=FsUGwq/YJR5IqXe80Bce121fdN0fIt872N4fWAVjFwP4/3gGetvn3qInwaycsJH1hD QqN7Yx4dWnV2jcRT0asp2N1sIR3rut6xZ3ZeEk8vzWucS37Xn34VRIQBD08I2jk9Kclz nexDlk+QxKoB47rrFggR4Xb9j5dPp7is2z5ncJqHC0Y6h3xTeJzA3g2GEMOsWvBQNjm6 1Ed1Y2PW76koVXCasC3IevlcoHt96eBU6AaIeY9+3s08ZZamUtsLjFckNY5zaM19TFA/ vRllQiWio2fyM8j0O+I5ee6QsQF2XHHQ180sdslSWd3RPt8xl7aAr9u66CLzoRhvEW75 xq5g== X-Forwarded-Encrypted: i=1; AJvYcCXoFZHX7ta3PQPy7uteJLId48ztmLE7zkm5bng80OKVM8nkq53W0Dkifts+TkOi47BsVxGpBXPHAhRVtlFz@lists.postgresql.org X-Gm-Message-State: AOJu0Yxh90u6pcGa5oqObQTyPRcH5N9lZxjF27oQ3yIav0ERTh8fjTWz j3YVye2qXrB8xwPnOu9Bapl7nh/SbWWIsisNLHEDbKBm9+mMEY8JzF/pSyTnNOSGPDAPXjHCt// wawNWOpyXWJ3Tp4rupuwoXP6wEA3gSZxuGAqP X-Gm-Gg: ATEYQzylGejoITKr5TfDE5Ty4rHB7PG6i1LHuVR0Mantsd/FNncFTSprLRU3znd+dyQ Jru1BSWKaZVYLrBHasdqmpKhVnRvTCMy3vUO2xAw+2qydOWcqRurBqsWjVq9HtjCxi90Zx2tEcV rPnTYxK7iL9VY49dPTczvOplaJgL9aI84kKKApi4MiexD/Cqnt74Y/R4BRDH+owwoVLe4oYrGwu 8DONTfInz5eYieTlcbueSfnrhg+7q+PvOxfzvTWKxob0SGEkbekbcJiGybursFBeIxb9swbvVXD c31tjIsseVsSRBmM8YOwQiW7hxn9u9wpjEad9H+1l1y/NVyiZg== X-Received: by 2002:a05:6512:114b:b0:5a2:9bd4:30c7 with SMTP id 2adb3069b0e04-5a2c1c9efe7mr292500e87.0.1774985415260; Tue, 31 Mar 2026 12:30:15 -0700 (PDT) MIME-Version: 1.0 References: <0c28fbd1-3320-4e9b-815c-6d62753aa063@wi3ck.info> In-Reply-To: From: Masahiko Sawada Date: Tue, 31 Mar 2026 12:29:37 -0700 X-Gm-Features: AQROBzAeU12nlg0jD-s7ZXr9MHsxAC4GseJlFK4sgGBQBATwIhPRHhVML3zJdvo Message-ID: Subject: Re: Initial COPY of Logical Replication is too slow To: "Hayato Kuroda (Fujitsu)" Cc: "Zhijie Hou (Fujitsu)" , Amit Kapila , Jan Wieck , "pgsql-hackers@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 31, 2026 at 4:39=E2=80=AFAM Hayato Kuroda (Fujitsu) wrote: > > Dear Sawada-san, > > Thanks for updating the patch! Few comments. Thank you for the 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 publis= hed in the > + * first place. If not, we can return early without check= ing 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_paren= t, gpt_test_sch.tbl_sch) WITH (publish_via_partition_root =3D 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 =3D tr= ue); > ``` > > It needs to be rebased due to 5984ea86. Agreed with the all above points. I'll fix them in the next version patch. > > 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 =3D GPT.relid AND > a.attnum =3D 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 =3D C.relnamespace) > WHERE C.oid =3D 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 =3D C.relnamespace) > - WHERE C.oid =3D GPT.relid; > + pg_class C JOIN pg_namespace N ON (N.oid =3D C.relnamespace), > + LATERAL pg_get_publication_tables(ARRAY[P.pubname], C.oid) GPT; > ``` I'm not sure the new API of pg_get_publication_tables() is better here since this view is going to get the publication information of all published tables, in which case the existing one might be faster. Also, if a few tables among a huge number of tables (or whatever relations) are published, checking all relations with the new API of pg_get_publication_tables() would be quite slow. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com