Re: Does idle sessions will consume more cpu and ram? If yes,how to control them

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Joshua White <joshua(dot)white(at)monash(dot)edu>
Cc: Raghavendra Rao J S V <raghavendrajsv(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
Date: 2018-12-20 01:27:18
Message-ID: 20181220012718.GI27104@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.
>>
>
> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2018-12-20 01:41:04 Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
Previous Message Joshua White 2018-12-20 00:32:22 Re: Does idle sessions will consume more cpu and ram? If yes,how to control them