pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor PgStat_TableStatus to new PgStat_RelationStatus
Date: Fri, 14 Aug 2026 00:08:16 +0000
Message-ID: <E1wufT5-00000000TcD-0c03@gemulon.postgresql.org> (raw)

Refactor PgStat_TableStatus to new PgStat_RelationStatus

This new structure is split depending on the stats kind it deals with:
- PGSTAT_KIND_RELATION, for tables.
- PGSTAT_KIND_INDEX, for indexes.

This change designs a cleaner barrier for the handling of stats data
related to tables and indexes, by being able to track precisely what are
the counters used by one or the other for pending data.  Using a common
ground for both eases the tracking of Relations in the relcache, with a
structure based on a union separated by stats kind.

The code originally pointed to some counters that may not be used at
all.  For example, indexes have no need for the tracking of
sub-transaction data, still the code implied that these could be touched
for an index.  A consequence is that PgStat_TableXactStatus is not
renamed, as it is not used by indexes.

Some asserts are added as an extra layer of protection to prevent the
update of fields that should not be touched.  find_tabstat_entry() and
find_tabstat_entry_kind() are removed, replaced by a single
find_relstat_entry_kind() able to work for indexes and the rest.

72a6dad1c911 took care of the shared memory and on-disk part of the
split.  This focuses on the pending data part at backend level.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/f572abe7-a1bb-e13b-48c7-2ca150546822@gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/utils/activity/pgstat.c          |   4 +-
src/backend/utils/activity/pgstat_index.c    |  30 +--
src/backend/utils/activity/pgstat_relation.c | 315 ++++++++++++++-------------
src/backend/utils/adt/pgstatfuncs.c          |  13 +-
src/backend/utils/cache/relcache.c           |   2 +-
src/include/pgstat.h                         | 112 +++++++---
src/include/utils/pgstat_internal.h          |   2 +-
src/include/utils/rel.h                      |   2 +-
src/tools/pgindent/typedefs.list             |   3 +-
9 files changed, 282 insertions(+), 201 deletions(-)



Message-ID: <E1wufT5-00000000TcD-0c03@gemulon.postgresql.org>
Permalink:  ../E1wufT5-00000000TcD-0c03@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wufT5-00000000TcD-0c03@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Refactor PgStat_TableStatus to new PgStat_RelationStatus
  In-Reply-To: <E1wufT5-00000000TcD-0c03@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox