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 1wAM2Q-002Ikj-39 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 06:05:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAM2O-005D0t-1M for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 06:05:16 +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 1wAM2O-005D0g-0J for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 06:05:16 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAM2M-00000001FVM-1BLp for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 06:05:15 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-8cfd122d78fso907761885a.3 for ; Tue, 07 Apr 2026 23:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775628311; cv=none; d=google.com; s=arc-20240605; b=bRdpwW4zYMbBEJvvHloie+nERZhUPR0HsVdwuxnRm9BicaXJ3J2NCaX9zwQdM5BbXp NhAcEFS7DsP7U3z/SVYI6/rOzYcqXYtcZ5ng53lemuItNgFMzgnRlyULLF8wHzX5Xutw 1B/EnR44m7MYsuYJkeDjShfj/FQGGX2kX1VLZnX0UN/OJM4U5vfnOSDY/lP3oxzwIFkK ktES0kQ152yltjsF/qxPyMXfZWD315YVPPfTHutI+ShAlKO0J50YPu+5mRxc2kyNJj3f LtypFlJJ42pwp60xaWwvfMgpoHzn8fO81Wc8TV/GvIh/DNwAwBvb+ES9oWRpdK9YQ/bA bJ6A== 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=t6wmlEUqND/agezE6ptz4v3SPO10Q8kUJ+zotssyjEs=; fh=Q995yeDNXKBGw4b8hOwNDi72c2jov9ChhXpMhJPxQso=; b=NpS1XR5XVTgQrqMEvw7MvmC9Gpj//gxZILMC54iDt2bIXCkCFwLYQPzjEfdGWs1QcV e7a41eIarfIQu0PRwzcSxqAL61T7jKl6vr5UWsLVFoeXaz2cMNaLh7yWBUeK67ZkWEd3 7nXbNvqTiNozPXmSvJ0FUvBaKebXCfmxSaujFfLmSo+QKw5E1Yt5XE1Wdd4CVffX6+WW fq5fv91eCX78wj2ibUDvq9TEDvQuj4y+Pd5FGSAshhULqvwdHvquiOKVJIUAR/LUNYAJ KGExqTc/X43lqh3uc4mS0eAoDjpes8zIaAbQ41UxG5FR8WOwmu27OrtiLEA/5MyoFvjo lmKw==; 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=1775628311; x=1776233111; 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=t6wmlEUqND/agezE6ptz4v3SPO10Q8kUJ+zotssyjEs=; b=CyMtqCHR/XfkfGGirM/MTJ2aUH4Fi0ZTnqZkXk9tQFMYcHE7milQI2vxOKJ4gq+sf3 +wlcObG4+TpNlcVmS/e9ObFa5Piy/xnCvktp4vDnlFeMbMhICE1gSLXb3P6t50VBmMVB +EOA2qrxJaKiHFF4Hht9YgJsxSbEZKNoG4BCLQhim9zTP5LEgtxJ+selj4Q/DQQf2d+a kkEGKSFJAPg4Jr80Dd99XszHXwAVop5cZpuN77lH9qRVC8Ra10EHiT//DdJH4W8dXxnZ xa0eqZuX+51YcWmw47HsmyMhnqVW2lIWxyM8S+foA+yjHd8gOWtQkP8r9M7yc6dyC81F 9rng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775628311; x=1776233111; 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=t6wmlEUqND/agezE6ptz4v3SPO10Q8kUJ+zotssyjEs=; b=Y1t6DRODwAWcrLCdvUIcUlSY2P/zuzh6v8PfuopZpp5jTIQ007z/L6CPiVvDed8KUM O2QYy4G9zfJWtlK9i9zGDqjvXZrEo1sDzQ4wkZXO9Iulb64S2itdVwOMAGvTBr2T78C1 EqKQPBE9oC+FsjX6jp2nfxX6Yf02MpEA2N684xepjVrUMmwR/bFz3sAIlwudMTcCc2Qq 3OhMaNgUAoeBodgFHM2fXr2eIWzR0Uz7dNJOkp/1JyLFTKUQRVfMcjtALWlu33oVRaM2 G9p/DGreGPXZZBzO9oz81bJRxmsN8yFRkgMapTJsNOl1HPxBp9Mxew4jYBm4qJd1I44g VRbA== X-Forwarded-Encrypted: i=1; AJvYcCUM55JWYQPdGypA7oHCbLWa8UpyHavF2cy6aspKLFgxaSY83E1lSOXwSLwJ5r3aQvtboor1hFoNJIlOvzZK@lists.postgresql.org X-Gm-Message-State: AOJu0YzHd2nSY4D+Sdvvw4CsRxR2m3xllkzNGW/3hOtlAnNiiYLL7diT uvNppwjJYsWx3XG9wTJPB8wJRSWrtpQqIKlqGzemD/1piO0j4CZsptDNE0JWBmIXeVnGpcBIfDO AvLPVv+Plxvl9M7seZ0UwL0Y7u+6LlNw= X-Gm-Gg: AeBDietfXUn9UoxY6yPdXs+fBFxc0dXBUClDCBCnSgN09up+bWBTDkCxcvsYLFgde59 0WIV+7hSbYHxGqeUOK3D/OGpEIGpVNKH+MuubBDEZ9JEUMPanr8+5Y+izFhEqxf3yfm4gF8N2Zy 6C4jAIUzl7umnqbgJHHwjud4HO12Vvgf38AcZh1lkTKbA2XklLe8pB1DW7VXSNiUjdMB8tEDgRc 7GWqNa8cH1DbteoNGknEqXjv8EpOi1AqWflGbgyU4X0HcS9OpWHdhQtBn1m7Aei2kWhiRU8/5Fn Vd5WNJasnRmkku1krTK/PnUIz0tjO5ztBoux+4SJjQ== X-Received: by 2002:a05:622a:4c1a:b0:50d:9f33:9a5 with SMTP id d75a77b69052e-50d9f33117dmr107531421cf.23.1775628311425; Tue, 07 Apr 2026 23:05:11 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Wed, 8 Apr 2026 16:04:45 +1000 X-Gm-Features: AQROBzDQULY4HUedzBpLYNnoToOcSz60HthotooLnNykI8bmTAiEyN-WlTtY2xw Message-ID: Subject: Re: Logical Replication - revisit `is_table_publication` function implementation To: shveta malik Cc: vignesh C , PostgreSQL Hackers 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 3:25=E2=80=AFPM shveta malik wrote: > > 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 = wrote: > > > > > > On Tue, 7 Apr 2026 at 12:32, Peter Smith wrot= e: > > > > > > > > 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 che= ck > > > > 'prexcept' anymore > > > > - more efficient. e.g. skips unnecessary scanning when puballtables= is 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 puballs= equences > > > > I think function is_schema_publication() is unrelated to 'puballsequenc= es'. > > > > 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? > Oh! You are right. (Sorry, Vignesh, I did not recognise that combination as unsupported). I'll post a patch update to handle it. =3D=3D=3D=3D=3D=3D Kind Regards, Peter Smith. Fujitsu Australia