Split index and table statistics into different types of stats

From: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Split index and table statistics into different types of stats
Date: 2022-10-31 13:14:15
Message-ID: f572abe7-a1bb-e13b-48c7-2ca150546822@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v1-0001-split_tables_indexes_stats.patch text/plain 94.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2022-10-31 13:15:44 Re: Proposal to use JSON for Postgres Parser format
Previous Message Tom Lane 2022-10-31 13:14:10 Re: Simplifying our Trap/Assert infrastructure