Max Malysh
Max Malysh

Reputation: 31545

PostgreSQL — measure logical replication lag

Is there a way to measure logical replication lag in PostgreSQL?

Upvotes: 5

Views: 5689

Answers (1)

Max Malysh
Max Malysh

Reputation: 31545

You can check pg_catalog.pg_replication_slots. Run this code on the master (publisher) server:

SELECT 
    slot_name,
    confirmed_flush_lsn, 
    pg_current_wal_lsn(), 
    (pg_current_wal_lsn() - confirmed_flush_lsn) AS lsn_distance
FROM pg_replication_slots;

lsn_distance is the measure of the replication lag.

Upvotes: 11

Related Questions