Обсуждение: [GENERAL] Postgres 9.x table/index stats reset timestamp

Поиск
Список
Период
Сортировка

[GENERAL] Postgres 9.x table/index stats reset timestamp

От
Dave Quello
Дата:

Hi,


Function pg_stat_reset_single_table_counters() resets stats for a single table/index that you typically query through pg_stat_user_tables or pg_stat_user_indexes, but there is no apparent way to retrieve the timestamp of the reset.  All stats in the db can be reset using pg_stat_reset() and the last reset date can be retrieved from pg_stat_database, but I’d prefer not to reset ALL stats when the focus is on a particular table/index.

 Are individual table/index reset timestamps stored?  If so, can they be retrieved?


Thanks,
Dave

Re: [GENERAL] Postgres 9.x table/index stats reset timestamp

От
Michael Paquier
Дата:
On Fri, Mar 3, 2017 at 3:03 AM, Dave Quello <dquello@gmail.com> wrote:
> Function pg_stat_reset_single_table_counters() resets stats for a single
> table/index that you typically query through pg_stat_user_tables or
> pg_stat_user_indexes, but there is no apparent way to retrieve the timestamp
> of the reset.  All stats in the db can be reset using pg_stat_reset() and
> the last reset date can be retrieved from pg_stat_database, but I’d prefer
> not to reset ALL stats when the focus is on a particular table/index.
>
> Are individual table/index reset timestamps stored?  If so, can they be
> retrieved?

The reset timestamp of each table entry is unfortunately not stored,
look at PgStat_StatTabEntry to see what's stored. Well we could have
that as well, it is important to be careful that the reset is updated
for all tables. Note that the timestamp reset happens in pgstat.c
actually. What you could do for now is to use a wrapper on top of
pg_stat_reset_single_table_counters() that calls now() and stores
timestamp on a custom table storing (oid,timestamp).
--
Michael