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 1wVTbd-001zN7-2M for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 12:24:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVTbc-00CL39-2F for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 12:24:56 +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 1wVRWX-00Bmh5-2l for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 10:11:33 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVRWW-00000001DgK-139F for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 10:11:33 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-45ef189aa1cso1244237f8f.0 for ; Fri, 05 Jun 2026 03:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780654291; cv=none; d=google.com; s=arc-20240605; b=gPHIMXjEf4gIequsYB/G8XPsNEgVTnQaUJxpg+ZRQM7pTJQbP71htNXwPNuhfHbP34 mGOikHAaBwIHyWvVniMyCGX+HvfRw57rVZrvFyD05O30rSuq7DhFN42OOaeSLJ1B/HaU t1WXc1NZxYvVnp2VDuN4p4QvOQazDOxSHzA13Uj2quuUZSFjLFfxJ0WlBcwXwEh1zi2X CSe84RuDSbgqZ/JXYtcc5alan/HGpReM7rwKskCconB2SIaV5qjwhQpRsZb2GPlqArWX 8/JyWOwqb3KvfEGJmAbDJyxsdwNMoq+V/KrlgxZlMNuj0KNMH1X1l+iXNwO9cAwaM3UH XfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=+YChljeFf8m+CItS+i+WMe2e+x4dQJpDK0tAhWHjh1E=; fh=/gQe77b11iMZdcPj/nJr/Ghqi6rQp5FPrPbdO93bmOA=; b=Iig8vlkmPQK7L+xZJK3tMdy66usMhK+1hrTmScfCozioPsl2ALZ5vWXF3dB8yqBzHM RSjt5CTYwlqQ7smTum7Az2v10NffGHeSuDnCiR7Cno3BT5ReohRG7ZaZtIMmksGYK1hx Tb5A0MVz84h98lShmqZSPKEyrXzHwFeBYhOhni+SMmC6AAnqUlHTelaGusBZItw1jHsO pss0nuCyTKt+lhxqdkdiKD7VL2wPkodzn6vfMniU2G3WrcDnDdudf32R9CyVniT6/tP9 rIPzhg/+hX/CIKsKRUAFaYlmcxjhMuYlAH30GKR2MYTWx4wl81YVEFzTMLtZ3czc9RD5 b+pQ==; 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=1780654291; x=1781259091; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=+YChljeFf8m+CItS+i+WMe2e+x4dQJpDK0tAhWHjh1E=; b=R/5xoekoTzHXCIpi4ug9R8ZYD8Kp7u5bqelJ917zqmqSgKZG3mSayVF2e/C28Zn97M 7Xq/qpfbNzUGkIpGhdHb9smGQkiaPfYbGDGkv30Wa+UuCJtXoMdkAdKYhZEfZ38Y9I6f +KbGxbJ7BBRvAChDwnKvLsmTbdgPsUcJ8ynQvslnTIBnaniSniKgKVRTc33H+HUDHzVg f5vxrdSKuEx6hzmss81po+7tMph099LNhQNOrDYfQH85AWF/mhN7lPbBYgnl6bL2Rrzp bHKd5ZS2TeHV6cIIpnQydVg/XkYHK5047PvzDWmNeOUbJk+tSDunVIVuxKggL7g6Fzck lIFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780654291; x=1781259091; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+YChljeFf8m+CItS+i+WMe2e+x4dQJpDK0tAhWHjh1E=; b=WVL702Yez1F2DL0V9Z/7ywoLuM50GpctYq/cEZ0gaLa7k/UMi6Uy0S3v2nicXzNvCy R3uu2b5Oc2nynBuBMN6h5wmGtVGolQZnNh+q5IxUC4yxR/H2VYxRG3R2mB9bsXLdtOSM do2EUEVKInaP413yNsjfZ5W0ZcmFi+2VxeZfDWVDVFSSvm86gMGVJqejGrT1ApajkKN3 xae3nFQ0X35+oL4MnHpNtgH76bIuSISgIpd+wX+Hiz47ujsnoYwYYxTup9XNkKJBDaPn h+8aPuKfPEeBSm+qDJU9wC1u1zlKhA8ijnCdUGnpFxLYjvy6uoRGMuLYOuEu3Fl3iuqW ubmw== X-Gm-Message-State: AOJu0YzMBD37YHQJwmgvDFjbfZCNfFBWFXvCztpmYtcpHoMPXRD2IKKK gAK8zZT+bltyPJtRLNOu6Xe+cFI+yukBtHQ96upaS6++2Kjsoebo3V0ikHYGmvaKo9PVoEFPR6k vVg/E6S09/D5C66zUoCiNhpYa9b9W2CjN+LyBgR2cug== X-Gm-Gg: Acq92OGr862Be9prm4TbAaCleveh6SxH8tb9oVKLSarYvjOPMoF8zXMLnP12yIMnvj/ vusDvFwTAcyTAf+1078qsEr06UGE5SBzGe4MI9VN/wpz2sWVViYqqNv98nzCv3GIkHsKxe2VDTu 4bgRX+dpDpGxTolbJKwqTwGRdTYai/k1qNa2wAcpqR+Aly8kxpCTnJC91trope7fd4JA2ps7wzS CygtrmI1ZgqLcX4tapxPoDBSTwqZNsXbjxce+2jBrzvRgBUyUzseF908oFpzKPGVcW28gsMBExt x9fIFobfwxrobAR92Q== X-Received: by 2002:adf:f0c3:0:b0:45e:891c:648e with SMTP id ffacd0b85a97d-460304ee12dmr3385048f8f.8.1780654290701; Fri, 05 Jun 2026 03:11:30 -0700 (PDT) MIME-Version: 1.0 From: "Crimean (gmail)" Date: Fri, 5 Jun 2026 12:11:19 +0200 X-Gm-Features: AVVi8CfO80OyJBGys9feRIugS9adVJ5k0UL7DWs0EBeEO9mpF1xV-oJUrp_XYMI Message-ID: Subject: Logical replication initialization time depends dramatically on the publication "schema" size To: pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000077144d06537ee27b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000077144d06537ee27b Content-Type: text/plain; charset="UTF-8" Hello, I would like to report a scalability issue I observed during logical replication initialization. The problem is not that replication fails or behaves incorrectly. However, initialization time appears to increase significantly as the number of tables in a publication grows. While investigating, I noticed the following query being executed: SELECT DISTINCT (CASE WHEN (array_length(gpt.attrs, 1) = c.relnatts) THEN NULL ELSE gpt.attrs END) FROM pg_publication p, LATERAL pg_get_publication_tables(p.pubname) gpt, pg_class c WHERE gpt.relid = 236073 AND c.oid = gpt.relid AND p.pubname IN ('p1'); According to AWS Performance Insights, this query shows an average latency of more than 130 ms and approximately 113,799 buffer hits per execution when the publication contains around 10,000 tables. As a result, the subscription initialization rate degrades from roughly 28 tables/second with 500 tables in the publication to about 8 tables/second with 10,000 tables. In my environment, replication itself works correctly, but initialization time increases substantially as publication size grows. Unfortunately, some of my deployments contain very large schemas, with over 1 million tables on the publisher side, making this behavior a practical problem. I can provide PostgreSQL version information, execution plans, and reproduction details if needed. Thank you for your time. Best regards, Sergii --00000000000077144d06537ee27b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hello,

I would like to report a scalability issue I observed dur= ing logical replication initialization.

The problem is not that replication fails or behaves incorrectly. However,= initialization time appears to increase significantly as the number of tab= les in a publication grows.

While inves= tigating, I noticed the following query being executed:

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) gpt,
     pg_class c
WHERE gpt.relid =3D 236073
  AND c.oid =3D gpt.relid
  AND p.pubname IN ('p1');

According to AWS Performance Insights, this query shows an average lat= ency of more than 130 ms and approximately 113,799 buffer hits per executio= n when the publication contains around 10,000 tables.

As a result, the subscription initialization rate degrades f= rom roughly 28 tables/second with 500 tables in the publication to about 8 = tables/second with 10,000 tables.

In my= environment, replication itself works correctly, but initialization time i= ncreases substantially as publication size grows. Unfortunately, some of my= deployments contain very large schemas, with over 1 million tables on the = publisher side, making this behavior a practical problem.

I can provide PostgreSQL version information, execution = plans, and reproduction details if needed.

Thank you for your time.

Best regards,
Sergii

--00000000000077144d06537ee27b--