Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save klaussilveira/554ca0feb7ac42663ac386f738fe8154 to your computer and use it in GitHub Desktop.
Save klaussilveira/554ca0feb7ac42663ac386f738fe8154 to your computer and use it in GitHub Desktop.
PostgreSQL: Find Lagged Replication
SELECT slot_name,
pg_wal_lsn_diff(
pg_current_wal_lsn(),
restart_lsn
) AS bytes_behind,
active,
wal_status
FROM pg_replication_slots
WHERE wal_status <> 'lost'
ORDER BY restart_lsn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment