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 1w7MzH-005EY9-00 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 00:29:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7MzF-007NEb-0G for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 00:29:41 +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 1w7MzE-007NEP-2S for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 00:29:41 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7MzC-000000025L7-1lv7 for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 00:29:40 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5a12cd0bcd8so3725696e87.3 for ; Mon, 30 Mar 2026 17:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774916978; cv=none; d=google.com; s=arc-20240605; b=ejbBa+V+Ey7auHKWTZ5FJ/p9K1okopnxOWelRCeE87RDCweX5OIbws2pLpDSgagUHC 8YRgm0DiWfBK69guB5KETbexQjd2aVfRDMwxOhvZGJtHOAA6pAWqqVV5pmeoFZsl4oQm 5wNpwyXVd8T16uTmJyWIrNVKLhB8RNQc4VhGpoHQZvcTQCbMnlkePgySll2cwUwlCepP LPF17d6WOKftViltSflnD3Z1FI8nKI3r/Q25pHc2JyarZXXADmGu9hZXqFcU2JYynH6E VbaNPZ+q23iZoeYk35u8b+KDG8n04JH+FQTFcjWcXPCFObfOAQk7zl0yzTWjISuDk+Nc OpRg== 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=5feJd24Aitcl/hzujk8LR2lZzvpZ8lRfyStKWoZd0Wc=; fh=pWByNaAU/20vpxemRwyz99nHtFWKUE8gVja6GH9+ZII=; b=VhQ1IvrZuXhxT41QsmB/F14V1y7unPdpkgR6ZS7BTaVrBZzO0eD14ZEfo/JL87Oe6S BbTTf8kvdg+dT1sZoLC+Paw8KUTfEG9f/xyC0NfGim2aq0a1XCoJxqWgDxaKdCtnyfWC 7P/UiGPk7v83lpziPgwGzCHQxHEzQE8sbXIHAUhh9sDRoVbXg+MUcOkCpF55VaivtRU4 ayuFdE0IU4OzvInvckT2L0fK6znhVp1CI3yFcHH0rUICMI30/DikW3eajCC26PF7+jqm wgyUZvIO7Evvl5e3PVcsMkzUNND0ODFdHk0M+nCKUXBGpMjQ0r8U1jjQqUFq52SwfdD4 9pag==; 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=1774916978; x=1775521778; 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=5feJd24Aitcl/hzujk8LR2lZzvpZ8lRfyStKWoZd0Wc=; b=it6mlQA2VVTeZy5fwNV3rEdH1kDZa7YmP1UZcfNeek4RbGeCVRR9SObIqyuGkfGCTk DG8jmSHoJFJel/QqXD16Rteq3az0s9TWFx2zTxhHzja2JOP3con2BBG5xa5GBMIB6fQP 7O+3CjF4t9umHfvzPWBxfpV0CGUqLcXtH2hXpINKN9AwqAII5T91maIvmHvB05ekl0jo vX1M05LKoDYVPA+Tw9ro9ABl2tPxBWlsV0mNwHTUb35MNEeHTf3lzV0H0DCNpjjUcSgw UbJqQjbmlY7rop4BM40LMNHB3jD4KMrb/hGHr/etvTybMu3q+EBID0OjXQ95Bf64VXPy SdiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774916978; x=1775521778; 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=5feJd24Aitcl/hzujk8LR2lZzvpZ8lRfyStKWoZd0Wc=; b=qrGLha7JshPyMpinyTQbsQE9PZ1vpfUnaWce+FcBuRsOrjXOcM9WPrHumnN6Np+ot8 yIbxivRqGqJicRhezjwkieulTn3YhRelCSko0we8XfFGnxWzWCSKds3rA70kiMH/dxnE yJIpSrrizur3ocgyBjGetxxoIz5K4u7aXGW1kwq7r22jWdNX8GEDxcLBZp3WBmSmENJY r4RFYmPeJSBpbrEdbrQXnGxPoaf+I3lxajHndYXt7aGMh1grsIpyUpaP1MaUUl3hxHij EV4o1fKr3n9nZRuUKy5ECLfrf0cwmdf1JtsjIWVcd0923BACDeupDmHxlqKVJQLuwjK6 uEJw== X-Forwarded-Encrypted: i=1; AJvYcCWRLbgkIqSE5uTfTOsjR3e2QN8eM48JZoSH2+9koOogSK5o0OX9gaA/NRFb6xd1KdEOlZJo+e9g5fj8ZES3@lists.postgresql.org X-Gm-Message-State: AOJu0Yz/R0NtwQF8zZdrny/nVB+MwN98thNghvRIwjdQQJVlyKBMTTGb MdS1dKhxrGB/PprLTJKRGn1Df1i8T49/1uoQSEmi910oQMAJmCUGbt1JDt+OpiwB5fFoqAngq/M JkEl8epZMDWGN1WClGO07VBC6McWWWQ4= X-Gm-Gg: ATEYQzxiyn+y4e7bLL6qgOHGXmaHsWRFskmiQOW9omK9Ks283UsSNs+MlgC1r0/EfL9 FOJvyiJokCcmEPo3jfOCmLRCy5u1f4BIDlBOeqcPbFpJIQBwShxn/XXj6q403MrWegbEO20YBcF vnFRKRKHKDvbKzXAu50S++cETimrLZ1vfzWIWu9DAYW2OQdie65DjKf7XUN5558oX1jgGaVe5aW 5neC8tWKOR8WDW7FhD9WXHLNnMTynx0wnrZ7bYacXnGSsw4JioYJI9zcWIY9Oa2dJoE9KguuXu4 DyME3Ykv X-Received: by 2002:ac2:4bc4:0:b0:5a2:7a4f:bd1e with SMTP id 2adb3069b0e04-5a2ab93e8d3mr5209553e87.45.1774916977672; Mon, 30 Mar 2026 17:29:37 -0700 (PDT) MIME-Version: 1.0 References: <0c28fbd1-3320-4e9b-815c-6d62753aa063@wi3ck.info> In-Reply-To: From: Masahiko Sawada Date: Mon, 30 Mar 2026 17:29:01 -0700 X-Gm-Features: AQROBzB6EfdQjEZiMw6S8IcClQNFTfeCd_45-5oHCv_GfBpY9D-u3xZe3eoDguQ Message-ID: Subject: Re: Initial COPY of Logical Replication is too slow To: "Hayato Kuroda (Fujitsu)" Cc: 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 Thu, Mar 26, 2026 at 1:35=E2=80=AFAM Hayato Kuroda (Fujitsu) wrote: > > Dear Sawada-san, > (Sending again because blocked by some rules) > > I ran the performance testing independently for the 0001 patch. Overall p= erformance looked > very nice, new function spent O(1) time based on the total number of tabl= es. > It seems good enough. > > Source code: > ---------------- > HEAD (4287c50f) + v4-0001 patch. > > Setup: > --------- > A database cluster was set up with shared_buffers=3D100GB. Several tables= were > defined on the public schema, and same number of tables were on the sch1. > Total number of tables were {50, 500, 5000, 50000}. > A publication included a schema sch1 and all public tables individually. > > Attached script setup the same. The suffix is changed to .txt to pass the= rule. > > Workload Run: > -------------------- > I ran two types of SQLs and measured the execution time via \timing metac= ommand. > Cases were emulated which tablesync worker would do. > > Case 1: old SQL > ``` > 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 17885 AND c.oid =3D gpt.relid > AND p.pubname IN ( 'pub' ); > ``` > > Case 2: new SQL > ``` > 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, 16535) gpt, > pg_class c > WHERE c.oid =3D gpt.relid > AND p.pubname IN ( 'pub' ); > ``` > > Result Observations: > --------------- > Attached bar graph shows the result. A logarithmic scale is used for the = execution > time (y-axis) to see both small/large scale case. The spent time became a= pproximately > 10x longer for 500->5000, and 5000->50000, in case of old SQL is used. > Apart from that, the spent time for the new SQL is mostly the stable base= d on the > number of tables. > > Detailed Result: > -------------- > Each cell are the median of 10 runs. > > Total tables Execution time for the old SQL was done [ms] Execution= time for the old SQL was done [ms] > 50 5.77 4.19 > 500 15.75 4.28 > 5000 120.39 4.22 > 50000 1741.89 4.60 > 500000 73287.16 4.95 Thank you for doing the performance tests! These observation match the results of my local performance test. BTW the new is_table_publishable_in_publication() can be useful other places too where we check if the particular table is published by the publication, for example get-rel_sync_entry(). It would be a separate patch though. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com