Created
April 25, 2018 14:24
-
-
Save adamjforster/0396242c6b171d0afa2c34fefb3ea8d4 to your computer and use it in GitHub Desktop.
SQL queries to show Postgresql streaming replication delay
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
/*** | |
* Secondary server commands. | |
*/ | |
// Show the number of seconds between now and the last replayed transaction. | |
SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT; | |
// Show the number of minutes between now and the last replayed transaction. | |
SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT / 60; | |
// Get last transaction log location received and synced to disk by streaming replication. | |
SELECT pg_last_xlog_receive_location(); | |
/*** | |
* Primary server commands. | |
*/ | |
// Get current transaction log write location. | |
SELECT pg_current_xlog_location(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment