-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added replication status for v10+
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
sql/Replication/Streaming/leader_replication_status_v10+.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Only for getting the status of those pids for streaming replication. | ||
-- | ||
SELECT client_addr, | ||
client_hostname, | ||
client_port, | ||
rs.slot_name, | ||
rs.slot_type, | ||
state, | ||
pg_wal_lsn_diff(pg_current_wal_flush_lsn(), flush_lsn), --in bytes | ||
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_flush_lsn(), flush_lsn)), | ||
pg_wal_lsn_diff(pg_current_wal_lsn(), write_lsn) as fromCurrentToWriteLSN, --in bytes | ||
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), write_lsn)) as fromCurrentToWriteLSN_pretty, | ||
write_lsn, sent_lsn, flush_lsn, replay_lsn, | ||
write_lag, flush_lag, replay_lag, | ||
rs.restart_lsn, rs.confirmed_flush_lsn, | ||
sync_state, sync_priority | ||
FROM pg_stat_replication sr JOIN pg_replication_slots rs | ||
ON (sr.pid = rs.active_pid) | ||
WHERE rs.slot_type = 'physical'; |