Hi,
Thank you for the reviews.
> > The write operation to beentry needs to be enclosed by
> > PGSTAT_BEGIN/END_WRITE_ACTIVITY(). In that perspective, it would be
> > better to move that writes to the PGSTAT_WRITE_ACTIVITY section just
> > below.
I have fixed it in the new version.
> > 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 ?
> > 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 ?
Regards,
Sergey