15.从复制详情:
(1)PGSQL 版本>=9.2:
非备机:
SELECT pid, application_name, client_addr, client_port, state, sync_state, (pg_xlog_location_diff(pg_current_xlog_location(),sent_location) / 1024)::bigint as sending_lag, (pg_xlog_location_diff(sent_location,flush_location) / 1024)::bigint as receiving_lag, (pg_xlog_location_diff(flush_location,replay_location) / 1024)::bigint as replaying_lag, (pg_xlog_location_diff(pg_current_xlog_location(),replay_location)/ 1024)::bigint as total_lag, (pg_xlog_location_diff(pg_stat_replication.sent_location, pg_stat_replication.replay_location) / 1024)::bigint as replication_byte_lag FROM pg_stat_replication
备机:
SELECT pid, application_name, client_addr, client_port, state, sync_state, (pg_xlog_location_diff(sent_location,flush_location) / 1024)::bigint as receiving_lag, (pg_xlog_location_diff(flush_location,replay_location) / 1024)::bigint as replaying_lag, (pg_xlog_location_diff(pg_stat_replication.sent_location, pg_stat_replication.replay_location) / 1024)::bigint as replication_byte_lag FROM
(2)其他 PGSQL 版本:
非备机:
SELECT pid, application_name, client_addr, client_port, state, sync_state, (pg_wal_lsn_diff(pg_current_wal_lsn(),sent_lsn) / 1024)::bigint as sending_lag, (pg_wal_lsn_diff(sent_lsn,flush_lsn) / 1024)::bigint as receiving_lag, (pg_wal_lsn_diff(flush_lsn,replay_lsn) / 1024)::bigint as replaying_lag, (pg_wal_lsn_diff(pg_current_wal_lsn(),replay_lsn) / 1024 )::bigint as total_lag, (pg_wal_lsn_diff(pg_stat_replication.sent_lsn, pg_stat_replication.replay_lsn) / 1024)::bigint as replication_byte_lag FROM pg_stat_replication
备机:
SELECT pid, application_name, client_addr, client_port, state, sync_state, (pg_wal_lsn_diff(sent_lsn,flush_lsn) / 1024)::bigint as receiving_lag, (pg_wal_lsn_diff(flush_lsn,replay_lsn) / 1024)::bigint as replaying_lag, (pg_wal_lsn_diff(pg_stat_replication.sent_lsn, pg_stat_replication.replay_lsn) / 1024)::bigint as replication_byte_lag FROM pg_stat_replication