| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, Daniel Gustafsson <daniel(at)yesql(dot)se>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Split index and table statistics into different types of stats |
| Date: | 2026-08-06 02:06:29 |
| Message-ID: | anPsJU7MvZF0PpD3@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Oct 02, 2024 at 01:48:11PM +0900, Michael Paquier wrote:
> It could always be re-created later on, as required.
And here is a blast from the past, following the recent effort I have
been putting for the relfilenode statistics:
https://www.postgresql.org/message-id/alCLr8ya-4ojew-x@paquier.xyz
One of the conclusions I got out of this initial work is that the
split of the index/table part makes more sense if tackled first, so
here we are.
As discussed, I am reposting refined versions of the patch set that
splits the index and table stats, by introducing a new stats kind for
indexes. There are two patches, split the facilities with different
consequences:
- 0001 refactors PgStat_StatTabEntry so as the data for indexes and
tables in shmem is split. The advantage of this one is a reduction of
the shared memory usage, as most of the fields of PgStat_StatTabEntry
are not used for indexes. These are hidden behind a new stats kind.
This is mostly bulk refactoring, with new SQL functions to retrieve
the stats info. Note the PgStat_TableStatus bits in pgstat_index.c;
these are tackled in 0002. This part is enough to reduce the shmem
footprint of index stats.
- 0002 is for the pending and [sub]xact data, with PgStat_TableStatus
refactored for a split with the index and relation stats. Perhaps I
should have been more aggressive with some of the renamings, but I've
left some of the existing shared tab references around, including some
of the static routines in pgstat_relation.c.
There are a couple of differences with the original patch posted on
this thread:
- First the relcache handling is simpler, with one pointer to what
could be either index or table stats. The original patch had two.
I was also looking at using two pointers as one approach, but found
that too complicated overall. So this patch set strikes with a better
balance.
- Split based on a relkind when copying the stats.
- The pending counts are the same, but I have need of less data for
the status data.
- The changes in pgstatfuncs.c get simpler, but that could be said as
well for the older patch with the macro-based approach we have
switched to in this file.
- The function renames are close to the original, but I have clarified
some of the tabentry bits, so as these refer to relations now.
- The subxact handling gets simpler, see around PgStat_RelXactStatus
and PgStat_IndexCounts, for example. Indexes don't need them,
removing some dead weight by splitting the structures.
With these in place, I would tackle the relfilenode part with the
rebuilding of tab stats data for autovacuum during recovery.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| v14-0001-Split-PgStat_StatTabEntry-into-separate-table-an.patch | text/plain | 47.1 KB |
| v14-0002-Refactor-PgStat_TableStatus-to-new-PgStat_Relati.patch | text/plain | 44.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-06 02:08:32 | Re: Fix archive restore race that could unlink WAL before rename |
| Previous Message | Yuefei Shi | 2026-08-06 01:52:40 | Re: Backup manifests accept out-of-range LSNs |