Split index and table statistics into different types of stats - Mailing list pgsql-hackers

From Drouvot, Bertrand
Subject Split index and table statistics into different types of stats
Date
Msg-id f572abe7-a1bb-e13b-48c7-2ca150546822@gmail.com
Whole thread Raw
Responses Re: Split index and table statistics into different types of stats  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi hackers,

Please find attached a patch proposal to split index and table 
statistics into different types of stats.

This idea has been proposed by Andres in a couple of threads, see [1] 
and [2].

To sum up:

We currently track index and table types of statistics in the same 
format (so that a number of the "columns" in index stats are currently 
unused) and we rename column in views etc to make them somewhat sensible.

So that the immediate benefits to $SUBJECT are:

- have reasonable names for the fields
- shrink the current memory usage

The attached patch proposal:

- renames PGSTAT_KIND_RELATION to PGSTAT_KIND_TABLE
- creates a new PGSTAT_KIND_INDEX
- creates new macros: pgstat_count_index_fetch(), 
pgstat_count_index_scan(), pgstat_count_index_tuples(), 
pgstat_count_index_buffer_read() and pgstat_count_index_buffer_hit() to 
increment the indexes related stats
- creates new SQL callable functions dedicated to the indexes that are 
used in system_views.sql

It also adds basic tests in src/test/regress/sql/stats.sql for toast and 
partitions (we may want to create a dedicated patch for those additional 
tests though).

The fields renaming has not been done to ease the reading of this patch 
(I think it would be better to create a dedicated patch for the renaming 
once the split is done).

I'm adding a new CF entry for this patch.

Looking forward to your feedback,

Regards,

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


[1]: 
https://www.postgresql.org/message-id/flat/20221019181930.bx73kul4nbiftr65%40awork3.anarazel.de

[2]: 
https://www.postgresql.org/message-id/20220818195124.c7ipzf6c5v7vxymc%40awork3.anarazel.de

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Simplifying our Trap/Assert infrastructure
Next
From: Matthias van de Meent
Date:
Subject: Re: Proposal to use JSON for Postgres Parser format