Re: pg_stat_database update stats_reset only by pg_stat_reset - Mailing list pgsql-hackers

From Daniel Verite
Subject Re: pg_stat_database update stats_reset only by pg_stat_reset
Date
Msg-id 9c504166-b65f-43c4-b388-6f738e4b7f48@manitou-mail.org
Whole thread Raw
In response to Re: pg_stat_database update stats_reset only by pg_stat_reset  (张连壮 <lianzhuangzhang@gmail.com>)
Responses Re: pg_stat_database update stats_reset only by pg_stat_reset  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
    张连壮 wrote:

> it reset statistics for a single table and update the column stats_reset of
> pg_stat_database.
> but i think that stats_reset shoud be database-level statistics, a single
> table should not update the column stats_reset.

This patch is a current CF entry at
https://commitfest.postgresql.org/23/2116/

The issue it addresses was submitted as bug #15801:
https://www.postgresql.org/message-id/flat/15801-21c7fbff08b6c10c%40postgresql.org

As mentioned in the discussion on -bugs, it's not necessarily a bug
because:

* the comment in the code specifically states that it's intentional,
in pgstat_recv_resetsinglecounter():

    /* Set the reset timestamp for the whole database */
    dbentry->stat_reset_timestamp = GetCurrentTimestamp();

* the commit message also states the same:

commit 4c468b37a281941afd3bf61c782b20def8c17047
Author: Magnus Hagander <magnus@hagander.net>
Date:    Thu Feb 10 15:09:35 2011 +0100

    Track last time for statistics reset on databases and bgwriter

    Tracks one counter for each database, which is reset whenever
    the statistics for any individual object inside the database is
    reset, and one counter for the background writer.

    Tomas Vondra, reviewed by Greg Smith


I can understand why you'd want that resetting the stats for a single object
would not reset the per-database timestamp, but this would revert a 8+ years
old decision that seems intentional and has apparently not been criticized
since then (based on searching for pg_stat_reset_single_table_counters in
the archives) . More opinions are probably needed in favor of this
change (or against, in which case the fate of the patch might be a
rejection).


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
Next
From: Tom Lane
Date:
Subject: Re: let's make the list of reportable GUCs configurable (was Re: Add %r substitution for psql prompts to show recovery status)