Re: Ned to understand why all the idle connections - Mailing list pgsql-general

From David Gauthier
Subject Re: Ned to understand why all the idle connections
Date
Msg-id CAMBRECB5-esarfYg5+TJd=k-XtBU3aeY=P2sCKEv3hNNQmu6Jg@mail.gmail.com
Whole thread Raw
In response to Re: Ned to understand why all the idle connections  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Ned to understand why all the idle connections
List pgsql-general
Thanks! 
And an example of connection pooling is pgBouncer ?


On Thu, Apr 23, 2020 at 2:41 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thursday, April 23, 2020, David Gauthier <davegauthierpg@gmail.com> wrote:
Hi:

psql (9.6.7, server 11.3) on linux

I have what appear to be a log of idle connections to my DB.  Query of pg_stat_activity indicates well over half (127/206) are like this...


dvdb=# select state_change,wait_event_type,wait_event,state,backend_type from pg_stat_activity where query = '';
         state_change          | wait_event_type |     wait_event      | state |         backend_type        
-------------------------------+-----------------+---------------------+-------+------------------------------
 2020-04-23 12:57:58.215854-04 | Client          | ClientRead          | idle  | client backend

What does this indicate?

The vast majority of the connections are through perl/dbi.   If a connection is made, and is currently not doing anything, does it appear in pg_stat_activity as "idle" ?  If, in DBI, $dbh->disconnect is used whenever the DB is no longer needed, will it disconnect from the DB and NOT appear as an idle in pg_stat_activity ?

If there are any other column s in pg_stat-activity you'd like to see, or any other query in any of the system tables, please advise.

If the server has an active, authenticated, connection/process running it shows up here.  Yes, idle is the state used to denote the the session is “not doing anything”...

$dbh->disconnect typically will indeed close the connection.  There can be exceptions if your architecture uses connection pooling.

David J.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Ned to understand why all the idle connections
Next
From: "David G. Johnston"
Date:
Subject: Re: Could Not Connect To Server