Last active
October 23, 2022 12:03
-
-
Save dsouzajude/b8d36321c170f0b266cefe4eae4e88bf to your computer and use it in GitHub Desktop.
Check the replica lag for a logical replication in terms of bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To be run in the source (publisher) database | |
* It checks the replica lag in terms of bytes between the source and destination databases in a logical replication | |
*/ | |
SELECT slot_name, | |
confirmed_flush_lsn, | |
pg_current_wal_lsn() as pg_current_wal_lsn, | |
((pg_current_wal_lsn() - confirmed_flush_lsn) / 1024 ) AS lsn_distance_kb | |
FROM pg_catalog.pg_replication_slots | |
WHERE slot_type = 'logical'; | |
/* | |
* Example output | |
* | |
* slot_name | confirmed_flush_lsn | pg_current_wal_lsn | lsn_distance_kb | |
* ----------+---------------------+--------------------+---------------- | |
* sub_all | 1DEB/F261E100 | 1DEB/F261E100 | 0.0000000 | |
* (1 rows) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment