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 1w56xT-002uAF-1g for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 18:58:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w56xS-008be9-0B for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 18:58:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w56xR-008bdz-2W for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 18:58:30 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w56xP-00000000vT3-1vtf for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 18:58:29 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5a27daa652fso5786991e87.0 for ; Tue, 24 Mar 2026 11:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774378707; cv=none; d=google.com; s=arc-20240605; b=MRPeVF/wpZN3SsnbVq8tvSWnRaavtJg4OSmrm4GcGSNqiOx21xomyD8iqkJTbWR7bC GWiKuIgOFCXZ9LowldXsxiPsizLV2F6Y2Na5OAU8qobT3UaVmm5KiKkl9Vmc0SlEirKh NE+JbcYw65Jeuy+6/f0mfIhyc2jTHSNSxzx2Xp9f2yGEY7g88bvq5RsaWsE182x91WJA yAOWgVJT7iRiPbmBMgMoD3jQ8/v2KXIqA+2Id8BpV0ZIYaDIMXyquqXQFUBY3Kk8NSjU zI0XAx1g787BLOdJ5R3nnAt2aBiCYrimex/gMez0pQY01EWIjIYdLcswBRaEheVa0jOD 15qQ== 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=P5dI5R5WJcyRaTDXh3k5IFqBV1b/T96q9KNMxywH9Jg=; fh=I/IuHjC89rB1ww0GlE4QDXteWKaeIhVJJPawBsHbTp4=; b=izXJjunIxWW2ZfjJplWL31NDQeAOwAS+IpMtQuICFgwLLFOnriMirQwDGNZfdJzKvf sZuzTgI77suz4/HKosvvnw4Z9WNhyPCw4wcKlGAoIbS6itEZLq9IAx/LlFbhVSw9DTAG MM9eowLG6zVWISicSGxqVfaM+1j2LjwZOFoX3c3GTW4UvMKXiOUWZnWuX7utkQCGI+Ad zoC7FxWAAralvpM7e+3448/EIrYk30C4byWid8tjHMu8Au9bIGliFYj9pPobv6WnXGTA hVW4KOTVbevJ1mvUbwc7ueUsUctkvBWCMNKuSAjK48qt2aLX0sdRTnHkPVBM2ZsHBt9S s0uQ==; 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=1774378707; x=1774983507; 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=P5dI5R5WJcyRaTDXh3k5IFqBV1b/T96q9KNMxywH9Jg=; b=NHMN4mfgESF+wbHiYw/TFh6Z/W4qLCoNkxL9/28pS4xI0Ej4LQ6HyPvi/GNxJPVS9b SWWS2kGTHOCNCgfm3iZz/ecO0ZFhttTf7BwCO3tQpi4PxmYhERyzSzO67PbC5V6WxD7G DFI3N7DB/whQdZnL0zUILznb4kPHDS2W5D0mF1pIXesvJ1PeYthsmkIUo+3PSZb7grI2 3ZDWuYtwo5ig0npDPxaMttAZrpNDJ76PdSgY9eH4IcWM8+a5tupqnZc1V3KJ7lcmt/2H os+SbjdRNBn0XoN4pTv9vWhGehWvtU+Yedd8+qqgHrucIW38rpPdClwMjep4J0vaA1A+ B0kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774378707; x=1774983507; 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=P5dI5R5WJcyRaTDXh3k5IFqBV1b/T96q9KNMxywH9Jg=; b=b/qipfJCGTPM8yq+FzZSoCyVf/wIW0yWFBuz5ov7iBqAGOtrBFuS6xpac0Ihj9xz22 w4ixZchgrzj7H1ZRGKGocukw/i1vuhQbKN2r712fzgkJvjGI+DzfbJncZWClC3SpmjGL vnK3vBeggPnYlcDh5lgUlGQdA2+HqzvhFV5+4Ued9G8WlNWF1hyr7vXqJfG9KAhdjDPE xk1quRP0kAOCfb9TUUqrSKK60eTLwayiOFn2yrTmcnLUH3nqjxFg1y6oWmR8PDigZqsY 3SxqzpLvp20oyM2A9NUgnoWliZgKooB+Qh7vYZ/8q7E57DVBN4+OF1VcjdOZ92UlzlLO 8SZg== X-Forwarded-Encrypted: i=1; AJvYcCU7xT4SN6duDOV2T3nI1xv99CCF7cdopdQFga99NRkw0P04qyAe7jGH1GJW8enyzmi6g0ekMo3pUR/Xx0oK@lists.postgresql.org X-Gm-Message-State: AOJu0YwRv61bFJ+M4DC+srytYgT0BBPnmdoYLBF8zjg1dMl2Wacv8Qz6 I/NuRf0Nev+uIKRURSXq5rsu8ljlC7lsk5DY64jkl4p4EGUgghi0FxxuKQdCDGUFXCVJhOkQBaH DKoU5xKgYDr26j57iuV8wpsl3C4Fi19Q= X-Gm-Gg: ATEYQzwnpAwRtuEaLaLZLGLxziBCcQcrce8ODn43Q7obbnG2gz2fGKhuKlr4z+/sqsA 4DCXjVKLybbe9lVVxYGH9I2fesqR1CAXqdfaCRbFM/dJhJjREgNs8ON0q4RPc6vCZwQMn+h0oVw M1EwC2NtG0jHKqVMhTdj0NBs8q9M3jXarZvCBhNGWhJufgOOgkqtzlI8DFVcqFJdWu/qASdunMF ewjWF71ZsO57VjA/AjcLnAnfh1RQtKqpBTMsDlqwdhKuZSKEgcxGDHrqaveetb4/8Gib2Xio3ho FYU/qDRqoFgH5k0IDNb9aGt/dADPWAEuoWP9mFNQWSuKpRn+ X-Received: by 2002:a05:6512:134e:b0:5a2:9bef:4fb0 with SMTP id 2adb3069b0e04-5a29bef4fc6mr116724e87.11.1774378707005; Tue, 24 Mar 2026 11:58:27 -0700 (PDT) MIME-Version: 1.0 References: <0c28fbd1-3320-4e9b-815c-6d62753aa063@wi3ck.info> In-Reply-To: From: Masahiko Sawada Date: Tue, 24 Mar 2026 11:57:50 -0700 X-Gm-Features: AQROBzCdrXoCEzFvybHOvElN_nWRT4XxVCFvTAhaFLzsXy6h1-rcpGcH-AMkTr4 Message-ID: Subject: Re: Initial COPY of Logical Replication is too slow To: Amit Kapila Cc: 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 24, 2026 at 3:47=E2=80=AFAM Amit Kapila wrote: > > On Thu, Mar 19, 2026 at 4:59=E2=80=AFAM Masahiko Sawada wrote: > > > > On Wed, Mar 18, 2026 at 3:31=E2=80=AFPM Masahiko Sawada wrote: > > > > > > > I've attached the patch to implement this idea. The patch still > > introduces a new function but it overloads > > pg_get_publication_tables(). We might be able to handle different > > input (array or text) in pg_get_publication_tables() better, but it's > > enough for discussion at least. > > > > * > + /* > + * We can pass relid to pg_get_publication_table_info() since > + * version 19. > + */ > + appendStringInfo(&cmd, > + "SELECT DISTINCT" > + " (CASE WHEN (array_length(gpt.attrs, 1) =3D c.relnatts)" > + " THEN NULL ELSE gpt.attrs END)" > + " FROM pg_publication p," > + " LATERAL pg_get_publication_tables(p.pubname, %u) gpt," > + " pg_class c" > + " WHERE c.oid =3D gpt.relid" > + " AND p.pubname IN ( %s )", > + lrel->remoteid, > + pub_names->data); > > Why in the above query we need a join with pg_publication? Can't we > directly pass 'pub_names' and 'relid' to pg_get_publication_tables() > to get the required information? Since the 'pub_names' is the list of publication names we cannot directly pass it to the pg_get_publication_tables(). But if we make pg_get_publication_tables() take {pubname text[], target_relid oid} instead of {pubname text, target_relid oid}, yes. And it seems to help somewhat simplify the patch. If having both pg_get_publication_tables(VARIADIC text[]) and pg_get_publication_tables(text[], oid) is not odd, it would be worth trying it. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com