Correct query to check streaming replication lag

From: Granthana Biswas <granthana(at)zedo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Correct query to check streaming replication lag
Date: 2014-01-14 06:31:10
Message-ID: CAACh-pXG=a_xyMKzj0odARyu0ZUiXOgymJEZ1omc_zL1BJqCcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All,

Can anyone please tell me which of the following is the correct replication
lag query to find streaming replication lag in seconds?

1. SELECT extract(seconds from (now() - pg_last_xact_replay_timestamp()))
AS time_lag;

2. SELECT CASE WHEN pg_last_xlog_receive_location() =
pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() -
pg_last_xact_replay_timestamp()) END AS log_delay;

Regards,
Granthana

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Felix Kunde 2014-01-14 12:34:25 Audit database to recreate former states using JSON functions
Previous Message Michael Paquier 2014-01-14 01:11:11 Re: question about checksum in 9.3