From: | Sergey Dudoladov <sergey(dot)dudoladov(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com> |
Subject: | Re: Add connection active, idle time to pg_stat_activity |
Date: | 2022-07-21 16:22:51 |
Message-ID: | CAA8Fd-pMc6rwGZUpesi2sfPaP-q85qwt06cSESTRDiAsNyuaLQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
I have addressed the reviews.
@Aleksander Alekseev thanks for reporting the issue. I have altered
the patch to respect the behavior of pg_stat_activity, specifically
[1]
> Another important point is that when a server process is asked to display any of these statistics,
> it first fetches the most recent report emitted by the collector process and then continues to use this snapshot
> for all statistical views and functions until the end of its current transaction.
> So the statistics will show static information as long as you continue the current transaction.
For the patch it means no computing of real-time values of
total_*_time. Here is an example to illustrate the new behavior:
=# begin;
=*# select total_active_time, total_idle_in_transaction_time from
pg_stat_activity where pid = pg_backend_pid();
total_active_time | total_idle_in_transaction_time
-------------------+--------------------------------
0.124 | 10505.098
postgres=*# select pg_sleep(10);
postgres=*# select total_active_time, total_idle_in_transaction_time
from pg_stat_activity where pid = pg_backend_pid();
total_active_time | total_idle_in_transaction_time
-------------------+--------------------------------
0.124 | 10505.098
postgres=*# commit;
postgres=# select total_active_time, total_idle_in_transaction_time
from pg_stat_activity where pid = pg_backend_pid();
total_active_time | total_idle_in_transaction_time
-------------------+--------------------------------
10015.796 | 29322.831
[1] https://www.postgresql.org/docs/14/monitoring-stats.html#MONITORING-STATS-VIEWS
Regards,
Sergey
Attachment | Content-Type | Size |
---|---|---|
0001-pg_stat_activity-add-total_active_time-and-total_idl.patch | text/x-patch | 15.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-07-21 16:28:07 | Re: let's disallow ALTER ROLE bootstrap_superuser NOSUPERUSER |
Previous Message | Tomas Vondra | 2022-07-21 16:19:48 | Re: Make name optional in CREATE STATISTICS |