Report replica identity in pg_publication_tables

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Report replica identity in pg_publication_tables
Date: 2025-06-30 10:13:45
Message-ID: CAExHW5sSmbnFCiMX=smSQSdaxkWPvZbMYaZq2bSE7+SD5wSWOA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,

The commit message in the patch says it all, but let me repeat it here.

When debugging issues with logical replication, replica identity
property of tables in publication is often useful, for example, to
determine the amount of data logged for an UPDATE or DELETE on a given
table.

Given a set of publications that a WAL sender is using,
pg_publication_tables can be used to get the list of tables whose
changes will be replicated including the columns of those tables and
row
filters. But the replica identity of those tables needs to be
separately found out by querying pg_class or joining pg_class with
pg_publication_tables on schemaname and relname. Adding the replica
identity column to pg_publication_tables avoids this extra step.

The replica identity of a given table is not a property of
publication, per say, so it's arguable whether it should be included
in pg_publication_tables or not. But the output seems to be useful.
E.g. from the tests

SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
pubname | schemaname | tablename | attnames | rowfilter |
replica_identity
----------+------------+---------------------+----------+-----------+------------------
testpub6 | public | rf_tbl_abcd_part_pk | {a,b} | (b > 99) | default
(1 row)

This line gives all the information related to logical replication of
table rf_tbl_abcd_part_pk together.

--
Best Wishes,
Ashutosh Bapat

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-06-30 10:25:38 Re: fix: propagate M4 env variable to flex subprocess
Previous Message Peter Eisentraut 2025-06-30 10:12:12 Re: [PATCH] Remove unused #include's in src/backend/utils/adt/*