Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZn7Z-0005vi-Rg for pgsql-general@arkaria.postgresql.org; Thu, 20 Dec 2018 01:27:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gZn7Y-0004jd-Fn for pgsql-general@arkaria.postgresql.org; Thu, 20 Dec 2018 01:27:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZn7Y-0004jW-7W for pgsql-general@lists.postgresql.org; Thu, 20 Dec 2018 01:27:28 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZn7V-0002Qs-IE for pgsql-general@lists.postgresql.org; Thu, 20 Dec 2018 01:27:27 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B119422017; Wed, 19 Dec 2018 20:27:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 19 Dec 2018 20:27:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=VkwI89urcaCVK+sq2QLo16+Z3JZ 0T95rqy0SOaq8x9E=; b=KR0ybE7GDVArmc087unYFx2dEwi93fS8Krm22oxCp99 oBvyY/AB9JXHBeFcqz4LhS5qZqCCM6eKF8ecwNq1cZmxz+ekA1k3cznXrJD/LZrG gs1PnvWZhyPijozeohy3yExTYrzHfqVU0x90YDMLT5Mm4FX/6jAxi6LciJPWNp+q FSFVbWRmScImp7UGmdzr9ai3hTiSqUIKsMmLtypwMFIyVD6N1qlh307A1IDap6uf sSxsrK80w8Khftk/IEEm2SPKKRCLPzotX4rC6iFt1umDtHrUnlC9+O0r3dCL5xAq mB/UsGtPpd3QwoiT2OrypL7iDPsNXWexe5gTuoBz3+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=VkwI89 urcaCVK+sq2QLo16+Z3JZ0T95rqy0SOaq8x9E=; b=GL3ZfY+YQJ+ogAt98Tg4Q9 WtLoY3eQ/uWf0M2QUw9//bqdHANvUJbjc+ro8cAKMBPvqQN1+xu8hWSAZT9f23Id +zPDDTjo08pcj4OKcGE4IIzpC7sShAixyIhQrBmy93cEn5XcVdsfCHjEgmsT8SrZ 3RR2UGxq+xT0uzyHSaevOj1bxA2L53VpbKsYpDtWAfM1H/7CkkjsmPzPANmv7La9 /RW+cnj6V1l6GOwrq8fArLaF2pvpwrlbTZS3amtRF+gMqCWhNopIbmfumglEi5CL 2iR1ileKWMtRLpVwcZ93OxQZcDBcin0WXl7o8IxsTNzz2nXlJgjJLTDz4NSEHXzw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudejvddgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtd dmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgt hhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqne cukfhppeeiuddrvdduhedrudefjedrudeivdenucfrrghrrghmpehmrghilhhfrhhomhep mhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 4EFBBE4559; Wed, 19 Dec 2018 20:27:21 -0500 (EST) Date: Thu, 20 Dec 2018 10:27:18 +0900 From: Michael Paquier To: Joshua White Cc: Raghavendra Rao J S V , pgsql-general@lists.postgresql.org Subject: Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Message-ID: <20181220012718.GI27104@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="73fGQZLCrFzENemP" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --73fGQZLCrFzENemP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 20, 2018 at 11:32:22AM +1100, Joshua White wrote: >> In my application, the idle sessions are consuming cpu and ram. refer the >> ps command output. >> >=20 > If you connect to the database, does select * from pg_stat_activity() show > a lot of idle connections? Each backend stores its own copy of the relation cache, so if you have idle connections which have been used for other work in the past then the memory of those caches is still around. Idle connections also have a CPU cost in Postgres when building snapshots for example, and their entries need to be scanned from a wider array, but usually the relation cache bloat is a wider problem. This can be countered with pgbouncer as connection pooling. -- Michael --73fGQZLCrFzENemP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlwa7/YACgkQnvQgOdby QH2tBxAAjxh5wZoflpg/oLCe+dnMsup9RmwU3YU40YsSzvnUHtbOAL14KpWBODOB ZBWmpPsdY/nu4cuxdnWWZupZrSCLCCxXv7bsiV5R2lWc5QKmwidyg3rbT6oRDfUz zTTz1XlCmGlLHnZwQF49dwOcT07aRW01QX7e6U1By26AIYgdpVDEmrUzBGcIGN/K iR2K/EbM+tSTC9xmI/1VS/roqQIzcxX9XsYWbQcnv13LzaCXdQAjgQV31bLB5ZS+ Cm+KoPAqHnpfaee2QYoGVMFoUhP8LCMfzmrbu19kBDFgUt0+x8FKXcGsdHot142l wdR7gNitSGIW9qwKEPEiIHsnnWadk5sym6EPTqz0191BCKuwYjdKPCKpPV9oUqvy FJy00dR68qIJBX3Ks/ITaO0/8/oCorApaF8EZrwblabNhGURiy7n6Vok5bJ8Ay8I Ua+OGeIDVh0dSASQ2Y+qhqPiZ8TdH6S8x0GcZ5ZIMZ6thFCNOQFOxG4TJeFMdLjD unMlWHzliURk0BgsIOmWX+Wm6f1anJbLRtK5EHEwJ9LhoLvLNDtT0pYhBK0RIFpn V/9Qmaqy5iSrAp5wDpyQlMQuEZ70sBEGP6Nm91Xi9bgwUBfQkdltUa59NfAT1QAE +3IMuKIN4T1hkvDLBU9BPN1vRQhmjEQheNqfO4ToBOl5nibDz70= =vpOO -----END PGP SIGNATURE----- --73fGQZLCrFzENemP--