How to determine replication lag

From: Murthy Nunna <mnunna(at)fnal(dot)gov>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: How to determine replication lag
Date: 2014-08-07 19:09:32
Message-ID: BD7563973EF8894D905C80593EE9A4ED42CBC9@MAIL01.fnal.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I am wondering if there is a way to find replication lag (in time seconds etc.) between primary and standby in case of STREAMING REPLICATION.

I can use the function pg_last_xact_replay_timestamp () as below. Only problem is IF THERE IS NO UPDATE ACTIVITY in primary database the output of the following query keeps increasing but in reality standby is in sync with primary data-wise.

SELECT EXTRACT (EPOCH FROM AGE(current_timestamp, pg_last_xact_replay_timestamp()) )

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Joseph Mays 2014-08-07 19:39:29 postgres-xc
Previous Message Craig James 2014-08-05 17:11:31 Re: Stuck LSI 9650SE-12 RAID Controller