Re: Handling idle connections

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rajesh Kumar <rajeshkumar(dot)dba09(at)gmail(dot)com>
Cc: Rui DeSousa <rui(at)crazybean(dot)net>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Handling idle connections
Date: 2023-09-25 03:34:54
Message-ID: 69504.1695612894@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Rajesh Kumar <rajeshkumar(dot)dba09(at)gmail(dot)com> writes:
> 1. I see lot of idle connections where application_name is blank and also
> query is blank, i am identifying only with user. In this case how do I
> identify which application is using idle connection?

If pg_stat_activity.query is empty, then that is a connection that has
*never* issued a query (because once it has, the query column reflects
the last query even when the session is idle). So apparently you have
a rather broken application that connects and then does nothing.

I'd suggest fixing the client side so that it sets application_name to
something that would help identify the situation. If the client is
libpq-based, you might be able to do this by setting the PGAPPNAME
environment variable in an invoking script, rather than modifying
any low-level code.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message mu88 2023-09-25 09:42:30 Seed pgAdmin roles with Active Directory groups when using Docker
Previous Message Rui DeSousa 2023-09-25 03:10:16 Re: Handling idle connections