Re: Add connection active, idle time to pg_stat_activity
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: sergey.dudoladov@gmail.com
Cc: pgsql-hackers@lists.postgresql.org, rjuju123@gmail.com,
kuntalghosh.2007@gmail.com, rafia.pghackers@gmail.com
Date: 2022-02-01T04:55:16Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove unstable pg_amcheck tests.
- cd3f429d9565 15.0 cited
Attachments
At Mon, 31 Jan 2022 15:11:56 +0100, Sergey Dudoladov <sergey.dudoladov@gmail.com> wrote in
> > > if (beentry->st_state == STATE_RUNNING ||
> > > beentry->st_state == STATE_FASTPATH)
> > > - pgstat_count_conn_active_time((PgStat_Counter) secs * 1000000 + usecs);
> > > + {
> > > + pgstat_count_conn_active_time((PgStat_Counter) usecs_diff);
> > > + beentry->st_total_active_time += usecs_diff;
> > > + }
> > >
> > > The two lines operates exactly the same way on variables with slightly
> > > different behavior. pgStatActiveTime is reported at transaction end
> > > and reset at every tabstat reporting. st_total_active_time is reported
> > > immediately and reset at session end. Since we do the latter, the
> > > first can be omitted by remembering the last values for the local
> > > variables at every reporting. This needs additional two exporting
> >
> > Of course it's typo(?) of "values of the shared variables".
>
> Could you please elaborate on this idea ?
> So we have pgStatActiveTime and pgStatIdleInTransactionTime ultimately
> used to report respective metrics in pg_stat_database.
> Now beentry's st_total_active_time / st_total_transaction_idle_time
> duplicates this info, so one may get rid of pgStat*Time counters. Is
> the idea to report instead of them at every tabstat reporting the
> difference between the last memorized value of st_total_*_time and
> its current value ?
Exactly. The attached first diff is the schetch of that.
> > > This needs additional two exporting
> > > function in pgstatfuncs like pgstat_get_my_queryid so others might
> > > think differently.
>
> What would be example functions to look at ?
pgstat_get_my_queryid..
And, it seems like I forgot to mention this, but as Kuntal suggested
(in a different context and objective, though) upthraed, I think that
we can show realtime values in the two time fields by adding the time
of the current state. See the attached second diff.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center