Re: Why are IDLE connections using cpu according to TOP.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: bubba postgres <bubba(dot)postgres(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Why are IDLE connections using cpu according to TOP.
Date: 2011-06-04 16:41:48
Message-ID: 26378.1307205708@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> writes:
> On Fri, Jun 3, 2011 at 3:15 PM, bubba postgres <bubba(dot)postgres(at)gmail(dot)com> wrote:
>> I have an overloaded DB and I see several IDLE connections that are using
>> significant CPU.. (Not Idle in transaction)
>> Why would an idle process be eating so much cpu? Or is it not actually idle?

> Because there's often a difference in time between when the process is
> sampled for how hard it's working and the output that says what it's
> doing. I.e. it was working hard, then when we looked at the part that
> says what it's doing, it's not idle.

Aside from the fact that top's measurements are time averages not
instantaneous, I believe it's also the case that when an idle backend
receives a new SQL command, it does a fair amount of parsing of the
command before it changes its reported "ps" state. (This is because
it has to parse the command before it knows what to put in the state.)
So these could be processes that just received complicated commands.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-06-04 16:49:05 Re: Postmaster holding unlinked files for pg_largeobject table
Previous Message David Johnston 2011-06-04 15:44:17 Re: Pl/pgsql function