Re: Add stats_reset to pg_stat_all_tables|indexes and related views - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Add stats_reset to pg_stat_all_tables|indexes and related views
Date
Msg-id aN+fdN6L8mN2YbzE@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Add stats_reset to pg_stat_all_tables|indexes and related views  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Hi,

On Fri, Oct 03, 2025 at 04:50:07PM +0900, Michael Paquier wrote:
> On Fri, Oct 03, 2025 at 05:33:00AM +0000, Bertrand Drouvot wrote:
> > On Fri, Oct 03, 2025 at 10:24:39AM +0900, Michael Paquier wrote:
> >> Makes sense to me.  This matters in terms of coverage for HEAD,
> >> being outside of the scope of this proposal.
> > 
> > Added one test on pg_stat_all_indexes in v2 attached. That's the first test
> > on "pg_stat_all_indexes" in .sql files. It just tests the new stats_reset field,
> > I think it's sufficient for the purpose of this patch.
> 
> But the fact that the reset function is able to work on indexes is
> something separate than this patch.  Wouldn't it be better to check
> some of the non-timestamp fields of pg_stat_all_indexes with a reset
> in a test that applies before the main patch?

Yeah, stats.sql is already doing some tests coverage on index stats (through
retrieving idx_scan and friends in pg_stat_all_tables) but the reset function
is not tested explicitly on indexes.

> That's a minor comment,
> sure, but this part feels like a separate item.  So I'd like to
> extract that as a patch of its own, then apply it as an independent
> piece.

That makes sense. Done in 0001 attached.

> > Yeah, it comes from 083e1b0f27df and the associated discussion is [1]. From what
> > I can see, at that time the struct that was holding the table and index stats
> > was "PgStat_TableCounts". So the naming "pg_stat_reset_single_table_counters"
> > somehow made more sense at that time.
> 
> Thanks for the history digging.
> 
> I have double-checked the whole patch, at it looks like you have the
> right coverage in terms of the docs and the system views, impacting
> the set of system views for pg_stat_{all,user,sys}_{tables,indexes},
> and same for the pg_statio_* counterparts.  So things look clear here.

Thanks! Attached v3, split in 2 sub patches as discussed above (0002 is same
as v2 except that the tests has been changed due to 0001).

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Fixing a few minor misusages of bms_union()
Next
From: David Rowley
Date:
Subject: Re: [PATCH] Add tests for Bitmapset