Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find Replica Identity for a Postgres table

Is there a way to see what kind of replica identity a Postgres table has, whether using pgAdmin or through a query?

like image 327
svakili Avatar asked Mar 19 '19 20:03

svakili


People also ask

What is replica identity in Postgres?

Among the many things to say about logical replication features added in PostgreSQL 9.4, REPLICA IDENTITY is a new table-level parameter that can be used to control the information written to WAL to identify tuple data that is being deleted or updated (an update being a succession of an insert and a delete in MVCC).

What is replication slot in Postgres?

A replication slot is a feature in PostgreSQL that ensures that the master server will retain the WAL logs that are needed by the replicas even when they are disconnected from the master.

What are Postgres subscriptions?

A subscription defines the connection to another database and set of publications (one or more) to which it wants to subscribe. The subscriber database behaves in the same way as any other PostgreSQL instance and can be used as a publisher for other databases by defining its own publications.


1 Answers

You can query the pg_class system catalog:

SELECT CASE relreplident
          WHEN 'd' THEN 'default'
          WHEN 'n' THEN 'nothing'
          WHEN 'f' THEN 'full'
          WHEN 'i' THEN 'index'
       END AS replica_identity
FROM pg_class
WHERE oid = 'mytablename'::regclass;
like image 148
Laurenz Albe Avatar answered Sep 19 '22 09:09

Laurenz Albe