pgsql: Avoid invalidating all RelationSyncCache entries on publication

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid invalidating all RelationSyncCache entries on publication
Date: 2025-03-13 04:00:15
Message-ID: E1tsZjz-002Ctd-1G@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Avoid invalidating all RelationSyncCache entries on publication rename.

On Publication rename, we need to only invalidate the RelationSyncCache
entries corresponding to relations that are part of the publication being
renamed.

As part of this patch, we introduce a new invalidation message to
invalidate the cache maintained by the logical decoding output plugin. We
can't use existing relcache invalidation for this purpose, as that would
unnecessarily cause relcache invalidations in other backends.

This will improve performance by building fewer relation cache entries
during logical replication.

Author: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Author: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Reviewed-by: Hou Zhijie <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Discussion: https://postgr.es/m/OSCPR01MB14966C09AA201EFFA706576A7F5C92@OSCPR01MB14966.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3abe9dc18892b9f69bb48a2eb21fbe5cf348a489

Modified Files
--------------
src/backend/access/rmgrdesc/standbydesc.c | 2 +
src/backend/commands/alter.c | 16 ++++
src/backend/commands/publicationcmds.c | 39 +++++++++
src/backend/replication/pgoutput/pgoutput.c | 8 +-
src/backend/utils/cache/inval.c | 125 ++++++++++++++++++++++++++++
src/include/commands/publicationcmds.h | 1 +
src/include/pg_config_manual.h | 8 +-
src/include/storage/sinval.h | 24 ++++--
src/include/utils/inval.h | 10 +++
src/test/subscription/t/007_ddl.pl | 85 +++++++++++++++++++
10 files changed, 302 insertions(+), 16 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2025-03-13 04:52:41 pgsql: Refactor convert_case() to prepare for optimizations.
Previous Message Thomas Munro 2025-03-13 03:00:35 pgsql: Fix read_stream.c for changing io_combine_limit.

Browse pgsql-hackers by date

  From Date Subject
Next Message Sadeq Dousti 2025-03-13 04:50:58 Re: Add connection active, idle time to pg_stat_activity
Previous Message Amit Langote 2025-03-13 03:51:43 Re: Question about duplicate JSONTYPE_JSON check