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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joshua White <joshua(dot)white(at)monash(dot)edu>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <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 04:45:20
Message-ID: 22292.1545281120@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joshua White <joshua(dot)white(at)monash(dot)edu> writes:
> On Thu, 20 Dec 2018 at 14:35, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> čt 20. 12. 2018 v 2:41 odesílatel Ron <ronljohnsonjr(at)gmail(dot)com> napsal:
>>> So it's best to kill connections that have been idle for a while?

>> sure - one hour idle connection is too old.

> I'd also assess closing the connection from the client end once its task is
> done - that would reduce the number of idle connections in the first place.

IMO, "has it been idle a long time" is the wrong question. The right
question is "how likely is it to start doing something useful soon".

Certainly, leaving sessions sit doing nothing for a long time isn't
helpful. They consume RAM, they have to be accounted for by other
sessions, and if you're doing any DDL, they consume CPU time
maintaining their own caches in response to catalog changes. But it's
also true that starting a new session has a lot of overhead --- so you
don't want to kill a session that was just about to start doing some
useful work.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mitar 2018-12-20 09:17:14 Watching for view changes
Previous Message Joshua White 2018-12-20 04:01:01 Re: Does idle sessions will consume more cpu and ram? If yes,how to control them