Re: Add connection active, idle time to pg_stat_activity - Mailing list pgsql-hackers

From Kuntal Ghosh
Subject Re: Add connection active, idle time to pg_stat_activity
Date
Msg-id CAGz5QCLxnOpcPdjz-P0N_e3oT7SP0rz+Z9VmXCzKNywMpmHpqQ@mail.gmail.com
Whole thread Raw
In response to Add connection active, idle time to pg_stat_activity  (Rafia Sabih <rafia.pghackers@gmail.com>)
Responses Re: Add connection active, idle time to pg_stat_activity
Re: Add connection active, idle time to pg_stat_activity
List pgsql-hackers
On Fri, Oct 22, 2021 at 1:53 PM Rafia Sabih <rafia.pghackers@gmail.com> wrote:
> To provide this information I was digging into how the statistics
> collector is working and found out there is already information like
> total time that a connection is active as well as idle computed in
> pgstat_report_activity[1]. Ideally, this would be the values we would
> like to see per process in pg_stat_activity.
It's definitely useful to know how much time a backend has spent for
query executions. Once you've this info, you can easily calculate the
idle time using this information: (now() - backend_start) -
active_time. But, I'm wondering why you need to distinguish between
idle and idle in transactions - what's the usage? Either the backend
is doing some work or it sits idle. Another useful information would
be when the last query execution was ended. From this information, you
can figure out whether a backend is idle for a long time since the
last execution and the execution time of the last query (query_end -
query_start).

You also need to update the documentation.

-- 
Thanks & Regards,
Kuntal Ghosh



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Rationalizing declarations of src/common/ variables
Next
From: Robert Haas
Date:
Subject: Re: Catching missing Datum conversions