Re: Meaning of query age in pg_stat_activity

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Jan De Moerloose <jan(at)sensolus(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Meaning of query age in pg_stat_activity
Date: 2018-01-29 23:11:44
Message-ID: a1492572-773d-57d3-f344-02053bfc6648@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/29/2018 03:06 PM, Jan De Moerloose wrote:
> Hi,
>
> I'm using the following to detect long running queries in a webapp that
> is high on cpu:
>
> SELECT pid, age(clock_timestamp(),query_start) as age, usename, query,
> state from pg_stat_activity order by age;

I would add WHERE state = 'active'

>
> When the cpu is 100% and the app slowing down, i can see that some
> queries have a long age.
> Running the same queries in psql is very fast, however. The db itself is
> low on cpu.
>
> Is the age value as i calculate it representing the time spent by the
> database to execute the query or does it also include the time to read
> the result ? In other words, if the client is starving on cpu, will i
> see higher values of age ?
>
> Regards,
> Jan

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan De Moerloose 2018-01-29 23:19:55 Re: Meaning of query age in pg_stat_activity
Previous Message Nikolay Samokhvalov 2018-01-29 23:10:37 Re: Meaning of query age in pg_stat_activity