how-to · database · postgresql

How to view a replication lag on PostgreSQL?

Problem

You'd like to know how big is the replication lag between master and slave on PostgreSQL.

Solution

You may run this query on your slave host:

SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT AS replication_lag;  

Read also

PostgreSQL Streaming Replication

Published:
comments powered by Disqus