Re: [GENERAL] Correct query to check streaming replication lag

2014-01-21 Thread Granthana Biswas
Hi Ray, We are already using the following query: 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; We cannot use pg_xlog_location_diff as we use postgresql 9.1.

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-21 Thread Granthana Biswas
Thanks a load Michael. This is really helpful. Regards, Granthana On Tue, Jan 21, 2014 at 12:19 PM, Michael Paquier michael.paqu...@gmail.com wrote: On Tue, Jan 21, 2014 at 2:33 PM, Sameer Kumar sameer.ku...@ashnik.com wrote: We are already using the following query: SELECT

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-21 Thread Granthana Biswas
Yes byte lag as well as it makes more sense. Regards, Granthana Regards, Granthana On Tue, Jan 21, 2014 at 11:03 AM, Sameer Kumar sameer.ku...@ashnik.comwrote: We are already using the following query: SELECT CASE WHEN pg_last_xlog_receive_location( ) = pg_last_xlog_replay_location()

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Granthana Biswas
Yes we already do that. Count the number of ready wal files. Regards, Granthana On Sat, Jan 18, 2014 at 9:39 PM, Sameer Kumar sameer.ku...@ashnik.comwrote: Well in that case monitoring pending wal bytes would make more sense. Regards Sameer PS: Sent from my Mobile device. Pls ignore typo

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
On Mon, Jan 20, 2014 at 1:53 PM, Granthana Biswas granth...@zedo.comwrote: Yes we already do that. Count the number of ready wal files. I guess a better place to check would be pg_stat_replication Check this discussion: http://www.postgresql.org/message-id/4f13ed11.6080...@gmail.com

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 12:41 PM, Sameer Kumar sameer.ku...@ashnik.comwrote: On Mon, Jan 20, 2014 at 1:53 PM, Granthana Biswas granth...@zedo.comwrote: Yes we already do that. Count the number of ready wal files. I guess a better place to check would be pg_stat_replication Check this

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
On Tue, Jan 21, 2014 at 12:12 PM, Michael Paquier michael.paqu...@gmail.com wrote: Mind you, here is a simple suggestion: SELECT application_name, pg_xlog_location_diff(sent_location, flush_location) AS replay_delta, sync_priority, sync_state FROM pg_stat_replication ORDER BY replay_delta

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 1:30 PM, Sameer Kumar sameer.ku...@ashnik.comwrote: On Tue, Jan 21, 2014 at 12:12 PM, Michael Paquier michael.paqu...@gmail.com wrote: Mind you, here is a simple suggestion: SELECT application_name, pg_xlog_location_diff(sent_location, flush_location) AS

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
We are already using the following query: 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; This is (delay) not the correct thing to monitor. We cannot use

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 2:33 PM, Sameer Kumar sameer.ku...@ashnik.com wrote: We are already using the following query: 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

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-18 Thread Sameer Kumar
Well in that case monitoring pending wal bytes would make more sense. Regards Sameer PS: Sent from my Mobile device. Pls ignore typo n abb

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-17 Thread Sameer Kumar
On Tue, Jan 14, 2014 at 2:31 PM, Granthana Biswas granth...@zedo.comwrote: Can anyone please tell me which of the following is the correct replication lag query to find streaming replication lag in seconds? IMHO none is 'correct'. :-) 1. SELECT extract(seconds from (now() -

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-17 Thread Sameer Kumar
On Fri, Jan 17, 2014 at 5:31 PM, Granthana Biswas granth...@zedo.comwrote: Thank you Sameer for your reply. Is there any other query that would help get exact replication lag? You 2nd Query is the most accurate you can get. 2. SELECT CASE WHEN pg_last_xlog_receive_location() =

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-17 Thread Granthana Biswas
Thank you Sameer for your reply. Is there any other query that would help get exact replication lag? Regards, Granthana Regards, Granthana On Fri, Jan 17, 2014 at 2:46 PM, Sameer Kumar sameer.ku...@ashnik.comwrote: On Tue, Jan 14, 2014 at 2:31 PM, Granthana Biswas granth...@zedo.comwrote:

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-17 Thread Granthana Biswas
Yes it's purely for monitoring purpose. Regards, Granthana On Fri, Jan 17, 2014 at 3:29 PM, Sameer Kumar sameer.ku...@ashnik.comwrote: On Fri, Jan 17, 2014 at 5:31 PM, Granthana Biswas granth...@zedo.comwrote: Thank you Sameer for your reply. Is there any other query that would help

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-17 Thread Ray Stell
On Jan 17, 2014, at 5:07 AM, Granthana Biswas granth...@zedo.com wrote: Yes it's purely for monitoring purpose. I use the pg_controldata cmd locally and via bash/ssh shared keys and compare various values that seem interesting such as Time of latest checkpoint, Latest checkpoint location.

[GENERAL] Correct query to check streaming replication lag

2014-01-14 Thread Granthana Biswas
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() =