Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Checking PostgreSQL Replication Delay

You can get the delay in bytes from the master side quite easily using pg_xlog_location_diff to compare the master's pg_current_xlog_insert_location with the replay_location for that backend's pg_stat_replication entry.

postgres=# SELECT
 pg_last_xlog_receive_location() receive,
 pg_last_xlog_replay_location() replay,
  extract(epoch FROM now()) -
  extract(epoch FROM pg_last_xact_replay_timestamp())
 )::int lag;

 receive   |   replay   |  lag
1/AB861728 | 1/AB861728 | 2027

the lag is only only important when receive is different than replay. execute the query on the slave


Popular posts from this blog

7 Steps to configure BDR replication in postgresql

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?


How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory