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

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Dave Quello <dquello(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres 9.x table/index stats reset timestamp
Date: 2017-03-03 00:31:36
Message-ID: CAB7nPqR3BCVz-gi5DiVmK9giFtxtmYfktbf3D69QNFYxfPk2_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 3, 2017 at 3:03 AM, Dave Quello <dquello(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message rob stone 2017-03-03 02:40:31 Re: CentOS 7.3, PostgreSQL 9.6.2, PHP 5.4 deliver array as string
Previous Message Scott Marlowe 2017-03-02 23:31:47 Re: PG on SSD