Re: Waiting connections postgres 10

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nicola Contu <Nicola(dot)Contu(at)gtt(dot)net>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, Alessandro Aste <alessandro(dot)aste(at)gtt(dot)net>
Subject: Re: Waiting connections postgres 10
Date: 2018-07-24 05:58:09
Message-ID: 20180724055809.GE4736@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 23, 2018 at 04:41:59PM +0000, Nicola Contu wrote:
> we used to monitor waiting connections with postgres 9.6.6 via this
> query:
>
> select count (*) from pg_stat_activity where wait_event IS NOT NULL

Please note that a wait event becomes NULL once it is reset, so what
this query does is to monitor backends which are not waiting on
something, not backends which are idle. Hence you would include
backends also doing some active work.

> select count (*) from pg_stat_activity where wait_event_type ='Client'
> and wait_event IN ('ClientRead','ClienteWrite') and state='idle'.
>
> Can anyone help me?

You are visibly looking for a WHERE clause defined with state IN
('idle', 'idle in transaction') when looking for connections waiting for
some activity to be generated by the application, which works also with
9.6.
--
Michael

In response to

Browse pgsql-general by date

  From Date Subject
Next Message basti 2018-07-24 12:44:45 DB Backup from WAL Slave
Previous Message Andres Freund 2018-07-23 23:51:00 Re: logical replication snapshots