DBA Hub

📋Steps in this guide1/1

Find lag in streaming replication

-- Find lag in bytes( run on standby)

postgresql configurationintermediate
by PostgreSQL
15 views
1

Find lag in streaming replication

-- Find lag in bytes( run on standby) --- Find lag in seconds( run on standby)

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
postgres#
SELECT pg_wal_lsn_diff(sent_lsn, replay_lsn) from pg_stat_replication;
postgres#
SELECT CASE WHEN pg_last_wal_receive_lsn() =
pg_last_wal_replay_lsn()
THEN 0 ELSE
EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) END AS lag_seconds;

Comments (0)

Please to add comments

No comments yet. Be the first to comment!