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 1wALPY-002I1N-0f for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 05:25:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wALPW-004znf-1H for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 05:25:06 +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 1wALPW-004znX-0L for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 05:25:06 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wALPU-00000001AKJ-2kSq for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 05:25:05 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2adbfab4501so22591845ad.2 for ; Tue, 07 Apr 2026 22:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775625904; cv=none; d=google.com; s=arc-20240605; b=SyNu3+Znnfks6dpLOj4EjWUK/3cD/TZB6hYl8b1Y2enKXZUEwFqpqct2jOyuILlKfA N+hAkO7NbkDdF1wietXC2aXigYBt61XT5FeewJrCfTJKuPPRi9LZdR8iTgkRaa5QlLdJ ZFWWW0RV9MMkUiC2pXic3Ow1ms2VqjObFYooMme+CRFl5zw0+NWojubN2HHjnBd1mvUl wdrEnPhIST2wPuLEI1TTNemRskkM2T5JVDwPA7kU3IPG1vREdZtQMWQrQ2G3nmBJqbo4 +7HAXlJoBKG2+hCDrUm2Kxcljos9LEmRswfqwx7gMZIsWXl5fb05mgRkHm8zYPCsaXa9 l0Rw== 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=DafVRuG4MxKD7GWaHLfUDo3G4YqSylqqEuKQWqvKYKQ=; fh=IXDFRVFFl9zL3uUhAGckWh3BGjA4WjrwAKGa98pQpL4=; b=GSz0b1fV113wBYcqvb3hDo7X8GAuyGBIY3tdAh53y7m+c2DLKDYiLXoQ9uB+qopwf5 C4DHYENj8mQzWPB1f3fyQu3g0MneOEOwCSPw1Zd3+Xmn53zjQhDoYewYtwFjCWxO5mvV gkHf6ckWPyO5HfNiQLWDX/+W7nFOIYL6KUR4fg1graL2SYOizP7zfWFBvGwoxT5Rg47f OB3lGCz0Xnan4vphV7CpwQNVB9ibei2EZVvpuhKD+FZYGO1eYrv1i/fU732Nlv7rOfGS CtTmzLXauJVFpRWqlj+bbJNxIGlamwQUCAxj75V38RZsGZVqtzg0FQNalyIXVgfdwJ+h uBBQ==; 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=1775625904; x=1776230704; 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=DafVRuG4MxKD7GWaHLfUDo3G4YqSylqqEuKQWqvKYKQ=; b=lS1JYeywlwuwfncGGZohRWqz04f6aFZDpx4C1S0tVE/eQ7a7x604Kx7RLJfbId6/b8 dZsUuXjumsO2stRJ0VFY3OS2tw8JgR94l+gxJomUAxWhTFmxKpFp2XxGz91xmsAPS+pA Of0PY9h5NhEE62F8Z7E+OBOVBo1hfYRe2WV9RGT2SIaUbabgOOA2YOc+NkiPHYM0UEPZ JioZcoDB50nHPTTy4KGafRLcxmm6dBB61xMzZ9SPPxVjoO0UXeHuMkYwCYZnYPGTDRvP fqM/vKNOkBnOs218aMSBIG6MN5CKTFTtjmovcainqzfGvDiXmBLxILIlTW4r5Wr65Jhz wmFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775625904; x=1776230704; 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=DafVRuG4MxKD7GWaHLfUDo3G4YqSylqqEuKQWqvKYKQ=; b=QJTac8SY7N7dQTKco/JvjMILMZXJYy+YCmHZg78+n3nWpYwktA+a4Ki4ufbjYZlhxu uK5l0gjdsg1MXUFIM2ZtvvupGiviR0AI9x0uEEP6OF6TClcgHzGgqFGNCbvwu/kdO+9l RS1YucS+8Ydt2nwpOlgGmE5A5su2Y+0+6/5gk0gPWHzZPwSufIIyLGublCT/gk4ZXM/N 9SHc1U7+B9p4hEPmqMUqYE2MjUeUmUwSO8ICCZuHw+KhtCaZlkPnuU0qAqIezp27R1SD Q3HHsmTm7vviNJOkwYsixk55qjO2SxYMVM5CqudWe+OUIqraHf+RDu7Klyo40JfU2ixd DOgA== X-Forwarded-Encrypted: i=1; AJvYcCXy8PlC3PGHO1r0dwqCSsedExt/KiI6ZI403ywocHQ1in/Wq+k76gXhuDWwa8zYw2k21I8069HNmxWPBhWX@lists.postgresql.org X-Gm-Message-State: AOJu0YyR107bkv96zBg75ajz7OJ4wYDBuA+6rBPz3+2ptn5tYFWFlAu7 fA2+ZUedIOH7D5fZq0LV8wrrWCAdpjVM+6iSLYyL9YZqN7QD6Iygxr/ARxuVav1So4DRIXXiRTN dJcrBNy8ocwGc1QmmPzdwRsQ/zk6pjLo= X-Gm-Gg: AeBDies4CNgEQ9oU9zveeKwFYNsEFqCiwPDWKGXKGLz4y8Oyd7vszZjJ9GIyb3a1Q8A ibCAjxxxNVCTuUKfFXnXQF5/5YQtem+rBVgijTzVMDlqM3o7vHrysLwcDe+7zY9fTLfLMb0Wc6v rzcTlhiJEGDYKNA/LRJq0slqO4pzQujIqXgUIEUujNkjWQ2eOCV/i7O/PjCsePKtB+DSW0zx6/L MRiFGFL98teAWfoQD8RE6yKhaSPHqauSr9NCoGFrp/JfhXIIiZZp1HHX9Xt0DPwZcSocA5ffzun 6RSODCzMs0v2heuT6xOhhm4xASLG5/nzO1jn1wVuYZVTWq3t0SipJA== X-Received: by 2002:a17:903:1b63:b0:2b2:497e:3f60 with SMTP id d9443c01a7336-2b2818de005mr203889045ad.33.1775625903707; Tue, 07 Apr 2026 22:25:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 8 Apr 2026 10:54:51 +0530 X-Gm-Features: AQROBzCagtyXbX4dWGtE93LNg9aLK0lH0ZV9TSkxnwqT1Qf7EI4PxnKCDtioAE4 Message-ID: Subject: Re: Logical Replication - revisit `is_table_publication` function implementation To: Peter Smith Cc: vignesh C , PostgreSQL Hackers , shveta malik 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 Wed, Apr 8, 2026 at 10:24=E2=80=AFAM Peter Smith = wrote: > > On Wed, Apr 8, 2026 at 1:45=E2=80=AFPM vignesh C wr= ote: > > > > On Tue, 7 Apr 2026 at 12:32, Peter Smith wrote: > > > > > > Hi, after confirming my understanding of pg_publication_rel [1], I > > > revisited some logical replication internal functions. > > > > > > Specifically. > > > * The `is_table_publication` function is for checking if the > > > publication has a clause like "FOR TABLE t1". > > > * The `is_schema_publication` function is for checking if the > > > publication has a clause like "FOR TABLES IN SCHEMA s1". > > > > > > Notice that neither of these ("FOR TABLE", "FOR TABLES IN SCHEMA") > > > clauses are possible simultaneously with "FOR ALL TABLES". > > > > > > And we can readily discover if "FOR ALL TABLES" (aka `puballtables`) > > > is present from the pubform. > > > > > > We can use this to optimise and simplify the implementations of the > > > `is_schema_publication` and `is_table_publication` functions. > > > > > > PSA patch v1. > > > > > > AFAICT, the result is: > > > - less code + simpler logic. e.g. is_table_publication does not check > > > 'prexcept' anymore > > > - more efficient. e.g. skips unnecessary scanning when puballtables i= s true. > > > - more consistent. e.g., both functions are now almost identical. > > > > > > Thoughts? > > > > Hi Vignesh. Thanks for reviewing! > > > I'm not sure if this additional check is sufficient in case of > > is_schema_publication. Checking only puballtables can exclude FOR ALL > > TABLES, but it still cannot distinguish regular table publications, > > empty publications, or sequence publications. In all of those cases, > > we still need to check pg_publication_namespace. > > Yes, this condition is only an optimisation for FOR ALL TABLES, as the > comment says. > > IMO, the overhead of 1 additional boolean check for cases where it > doesn't help is an insignificant trade-off for the savings when it can > return false. > > > And also why just check for puballtables why not to check for puballseq= uences > > I think function is_schema_publication() is unrelated to 'puballsequences= '. > > e.g. all the following will still need to check > pg_publication_namespace, regardless of the 'puballsequences' value. > > ex1. CREATE PUBLICATION ... FOR ALL SEQUENCES; > ex2. CREATE PUBLICATION ... FOR ALL SEQUENCES, FOR TABLES IN SCHEMA s1; > ex3. CREATE PUBLICATION ... FOR TABLES IN SCHEMA s1; > IIUC, we don't support mix of ALL SEQUENCES and TABLES IN SCHEMA s1. So I could not understand your point, why FOR ALL SEQ still need to check pg_publication_namespace? thanks Shveta