Subject: pgsql: Avoid invalidating all RelationSyncCache entries on publication

From: Amit Kapila <[email-masked]>
Date: Thu, 06 Mar 2025 08:55:55 +0000

Avoid invalidating all RelationSyncCache entries on publication change.

On change of publication via ALTER PUBLICATION ... SET/ADD/DROP commands,
we were invalidating all the relations present in relation sync cache
maintained by pgoutput. We need to invalidate only the relation entries
that are changed as part of publication DDL.

We have ensured that the publication DDL execution generated the
invalidations required to invalidate impacted relation sync entries in
RelationSyncCache.

This improves the performance by avoiding building the cache entries for
the cases where a publication has many tables but only one of them is
dropped.

Author: Shlok Kyal <[email-masked]>
Author: Hayato Kuroda <[email-masked]>
Reviewed-by: Hou Zhijie <[email-masked]>
Reviewed-by: Amit Kapila <[email-masked]>
Discussion: https://postgr.es/m/[email-masked]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/588acf6d0ec15d9384c2f712585c0f56936d7bac

Modified Files
--------------
src/backend/replication/pgoutput/pgoutput.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)