Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkcNj-00FEn9-Af for pgsql-admin@arkaria.postgresql.org; Mon, 25 Sep 2023 03:35:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qkcNh-00D4uq-Qm for pgsql-admin@arkaria.postgresql.org; Mon, 25 Sep 2023 03:35:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkcNB-00D19L-KT for pgsql-admin@lists.postgresql.org; Mon, 25 Sep 2023 03:35:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkcN8-007PHk-Qg for pgsql-admin@lists.postgresql.org; Mon, 25 Sep 2023 03:35:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 38P3Ysol069505; Sun, 24 Sep 2023 23:34:54 -0400 From: Tom Lane To: Rajesh Kumar cc: Rui DeSousa , Pgsql-admin Subject: Re: Handling idle connections In-reply-to: References: Comments: In-reply-to Rajesh Kumar message dated "Mon, 25 Sep 2023 03:37:25 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <69503.1695612894.1@sss.pgh.pa.us> Date: Sun, 24 Sep 2023 23:34:54 -0400 Message-ID: <69504.1695612894@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rajesh Kumar 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