Re: [GENERAL] Postgres 9.x table/index stats reset timestamp - Mailing list pgsql-general

From Michael Paquier
Subject Re: [GENERAL] Postgres 9.x table/index stats reset timestamp
Date
Msg-id CAB7nPqR3BCVz-gi5DiVmK9giFtxtmYfktbf3D69QNFYxfPk2_A@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Postgres 9.x table/index stats reset timestamp  (Dave Quello <dquello@gmail.com>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: [GENERAL] PG on SSD
Next
From: rob stone
Date:
Subject: Re: [GENERAL] CentOS 7.3, PostgreSQL 9.6.2, PHP 5.4 deliver arrayas string