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 1w8As7-000HCK-2h for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Apr 2026 05:45:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8As6-004729-1v for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Apr 2026 05:45:39 +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 1w8As6-004721-0a for pgsql-hackers@lists.postgresql.org; Thu, 02 Apr 2026 05:45:38 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8As4-000000008K0-1dwl for pgsql-hackers@lists.postgresql.org; Thu, 02 Apr 2026 05:45:37 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5a2b542cbaaso610705e87.0 for ; Wed, 01 Apr 2026 22:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775108734; cv=none; d=google.com; s=arc-20240605; b=b4VUYU/GgWFsGKjkfbXOUHsyZ5orSvERwfwAq/SWGs9W+6/XBghLIT461t11z+R3px qvUB542znL/EwIDKUBAVg6TRaJRm2EII8s3WvXHE3TxvMwpsfOnVKt9sq2XhMIuLZ9ue dCjELOM0Aq+lHx7SDqgcTRxZ5Tzuy+e0AzH/P5RvZVnkiV/AwRQXyPsM05k2EMQblhVz BLNeNtCOoSLKeF6ngfYq7ozXzwQIPdK2se66l0zTqhqGAbsKi3+dyYqIj+ahhefb5bDl L2HdPAi0wfdwEo4emjZdzQVbDL8B/Kfd0lial6aqpPOYzEskEXsk7GC06pwf73sYQSTZ 0B3w== 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=YdLfUR2UlYn14MT509y41FpdVkcSF+r6zih6Tc1wqNk=; fh=L30Ll4VV0Z+00Ol4TRNq9AUqqrFuXJdePzu1wcxvcfk=; b=HA0zkZ3vvbtC8hBk92wnRSTAq/6mSfOZlVDz99srfdPfZGyYpQ7qUd21YHuU0U5ase Hq31lFFkKcOzHY99dxFoVQMJbFuMISDXKsY+vvqzSbJuhU4FM/YSLLXrOqdBMQgF0+A8 cyoOcAXmZAZEYAS3uqW+Dvr8m8BIhuZ0qlVXu4mpujR1u1/P79ATn54N6gABTL2sKJJt vTVeYpwrWxCAZm7VsAOSkxVhxQYzZiXRjTAFl7tJws58RPNwzyE2EF8IFuU97qgawRVb eL89phZsZYDWINTvQjtyEjeKx4UDODEAb8gTs37LeCROKAv+MgYNai/7O/mPmIUQzwmP KXOA==; 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=1775108734; x=1775713534; 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=YdLfUR2UlYn14MT509y41FpdVkcSF+r6zih6Tc1wqNk=; b=H2t0+a3xErX8rEpcdSQkwTaMLFh4F+FAR5xAbnfo5nLUD6HrKsp2aL20o8s8DPFc7V bTdZsv+RiaMRIbxGUMSLQspyVGKb0OB9is5iV2+aX/X8Wxa7W3fUJg3SzbQggD+634Nn k/aNVxpgECS99Ge15s22JnmN06q5p+ETvqq2GtcFt8GqtbCuRnbwfEJlnluz+LJbfN// CmFgrv4i4l1YaPBUKgyOvf/kcgONtk24UPVLR9PBlCCIEw14rj/vS6jGWqxW0LdICsy0 C5uRyUvq2eLlJBewyn9s8TcG4Ko6liZXSi7FtSv/IOAFa8/DK9Wj5anzqrCXfmzgtAFP vhLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775108734; x=1775713534; 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=YdLfUR2UlYn14MT509y41FpdVkcSF+r6zih6Tc1wqNk=; b=NAodDih6lSI2dGosoY/a0RCpX4ZijSlDmkiy5KV3hYHxkjNwfRlqcy7AvZOkNL/LG2 9+OCHgzkl7HSvcbaSMwUfnX3qYXOOz7ISNVlSIu9sdBh+ZEQxueTCQzFZhNvxnQvFtak +9rgn33VFNlSkJEd1OGVTDaZnumeZBMn6T+9L5q+tE49FG8FXVajGxF/4ajzupBrmRes UOM+WG4sRoKG1VK8h8TC5ISGdI321+MOG/7mw8fIpN5RJpw4YqbCYG/oZnYiwM25SFNN ufw6S0cIcvLjX4f0+e0kYUfwORyXJr3EJpJEDIyMATBuIm0TheQ0VuChc97HddttDs4e seZQ== X-Forwarded-Encrypted: i=1; AJvYcCVAg+eAcnEYYAXG7U5jMX/2C+xLPF67x6std6/5sR2tNLUrllzFkcQWVbCXZx7tb8Vfm/Ws3mJoRU8enYmx@lists.postgresql.org X-Gm-Message-State: AOJu0YyQ1A5TN3Ygum4D/NFyHyQaHl8FS1agjvjZUUWrguDllci6jKYN fHzpRUofDRs6qCuE1uiOUEVeo41BMFa1s6oN461WggGtrFvJBxUzSPxsIUycOsPhNDnCfGcJohb gYwGq1a/VKJB39n6gHhzMWFbiKeFhoqQ= X-Gm-Gg: ATEYQzyKpfnghN63RKNG0aTh6Tbwv9lk/QcHq79+JQ2vkv1LJ9jS7SMzxl4/EC3HEyp /MP2oSONtDp3kQ1/w/8M9B/10JDGzUoZ9DiGi2sJbo5Nn7gGUyxlv3RaGNy/mt02guV3Ac1W7Jr owbE/P5QZV4v/UdDNCYzWx9SJraxyF6cH7s4OYQpIZIkzNLut7pgMPF+uWG5O88npBpdS5ARPMl mr9x7XHzTUJA+wHnbowb4U15/VnSG8nINN93FvC1aYlqcK6eZ1SNItIIqtwS3HRoKsAv7FM2L9d 80JItSVd8vnBt3ykk66flq2MXgrOurII4RBNyhqRB8NnsEklGqk= X-Received: by 2002:a05:6512:3a93:b0:5a2:c0cf:451c with SMTP id 2adb3069b0e04-5a2c9957b1fmr246585e87.24.1775108733325; Wed, 01 Apr 2026 22:45:33 -0700 (PDT) MIME-Version: 1.0 References: <0c28fbd1-3320-4e9b-815c-6d62753aa063@wi3ck.info> In-Reply-To: From: Amit Kapila Date: Thu, 2 Apr 2026 11:15:21 +0530 X-Gm-Features: AQROBzCoCVha7nwGQntDYnNnD-IEgmAnImsuVAqHSV8gJum3cRWV2B0P9CVOlJs Message-ID: Subject: Re: Initial COPY of Logical Replication is too slow To: Masahiko Sawada Cc: "Zhijie Hou (Fujitsu)" , Peter Smith , 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, Apr 2, 2026 at 3:53=E2=80=AFAM Masahiko Sawada wrote: > > On Tue, Mar 31, 2026 at 12:40=E2=80=AFPM Masahiko Sawada wrote: > > > > On Tue, Mar 31, 2026 at 5:07=E2=80=AFAM Zhijie Hou (Fujitsu) > > wrote: > > > > > > On Tuesday, March 31, 2026 5:36 PM Amit Kapila wrote: > > > > > > > > On Wed, Mar 25, 2026 at 2:19=E2=80=AFPM Peter Smith > > > > wrote: > > > > > > > > > > There are many return points, and most of those "if" blocks canno= t > > > > > fall through (they return). > > > > > > > > > > I found it slightly difficult to read the code because I kept hav= ing > > > > > to think, "OK, if we reached here, it means pubviaroot must be fa= lse," > > > > > or "OK, if we reached this far, then puballtables must be false, = and > > > > > pubviaroot must be false," etc. > > > > > > > > > > > > > I can't say exactly why, but I find it difficult to read this funct= ion. So, I share > > > > your concerns about the code of this function. > > > > Because of its complexity it is difficult to ascertain that the fun= ctionality is > > > > correct or we missed something. Also, considering it is correct tod= ay, in its > > > > current form, it may become difficult to enhance it in future. > > > > > > > > > > I attempted to refactor the code a bit based on my preferred style, a= s shown in > > > the attachment. While the number of return points couldn't be reduced= , I tried > > > to eliminate if-else branches where possible. Sharing this top-up pat= ch as a > > > reference for an alternative style that reduces code size. > > > > > > > Thanks. It looks like a good refactoring! I'd prefer to free the > > ancestors list to avoid memory leak. > > > > I've attached the patch that incorporated all comments I got so far. > > Feedback is very welcome. > > > > I decided to simplify the code flow in the > is_table_publishable_in_publication() by taking more proposed changes > from Hou-san while accepting some memory leak. This function is > limited to be used only in per-call-memory context so we don't need to > worry about the actual memory leak. While we would need to change this > function in the futuer when we want to use it other places too, I > think it would be better to keep the function simple until then. I > hope the added new comment also help understand the code flow of this > function. > Yes, the function looks better and helps to understand the flow. Thanks for improving it. --=20 With Regards, Amit Kapila.