pgsql: Add stats_reset to pg_stat_all_{tables,indexes} and related view

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add stats_reset to pg_stat_all_{tables,indexes} and related view
Date: 2025-10-06 06:31:46
Message-ID: E1v5el8-000ITY-0r@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add stats_reset to pg_stat_all_{tables,indexes} and related views

It is possible to call pg_stat_reset_single_table_counters() on a
relation (index or table) but the reset time was missing from the system
views showing their statistics.

This commit adds the reset time as an attribute of pg_stat_all_tables,
pg_stat_all_indexes, and other relations related to them.

Bump catalog version.
Bump PGSTAT_FILE_FORMAT_ID, as a result of the new field added to
PgStat_StatTabEntry.

Author: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Sami Imseih <samimseih(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/aN8l182jKxEq1h9f@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a5b543258aa29e181abe59b3183b685650d24651

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 36 ++++++++++++++++++++++++++++
src/backend/catalog/system_views.sql | 12 ++++++----
src/backend/utils/activity/pgstat.c | 1 +
src/backend/utils/activity/pgstat_relation.c | 6 +++++
src/backend/utils/adt/pgstatfuncs.c | 3 +++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 4 ++++
src/include/pgstat.h | 4 +++-
src/include/utils/pgstat_internal.h | 1 +
src/test/regress/expected/rules.out | 36 ++++++++++++++++++----------
src/test/regress/expected/stats.out | 34 ++++++++++++++++----------
src/test/regress/sql/stats.sql | 11 ++++++---
12 files changed, 117 insertions(+), 33 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-10-06 07:15:48 pgsql: Remove block information from description of some WAL records fo
Previous Message Michael Paquier 2025-10-06 05:35:54 pgsql: Add test for pg_stat_reset_single_table_counters() on index