agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Split transaction data out of pgstats table counters
Date: Thu, 10 Sep 2026 04:56:46 +0000
Message-ID: <E1x4Wq5-00000004EhQ-0EsC@gemulon.postgresql.org> (raw)

Split transaction data out of pgstats table counters

At backend level, PgStat_TableCounts currently stores all the per-table
pending counters in one structure.  This is now split into two parts,
with the transactional part of the data moved out of PgStat_TableCounts
into its own structure labelled with an "xact" in PgStat_RelationStatus.

While on it, move truncdropped out of the counters and into
PgStat_RelationStatus so as both structs (existing PgStat_TableCounts
and new PgStat_TableCountsXact) contain only counters.  The previous
state was slightly confusing: this flag is a state tracking if a
relation has been truncated at backend-level, and not a counter.

Because truncdropped no longer lives inside PgStat_TableCounts, this
commit teaches the flush callback to treat a pending truncate as
sufficient reason to flush, even when both counter structs are otherwise
all zeros.

This refactoring work is in preparation of a different patch that wants
to introduce the concept of transactional stats data flush.  Compared to
all the other stats kinds, relations are an exception as they mix
transactional and non-transactional data.

Author: Sami Imseih <samimseih.pg@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aoU32VTkUtpdUewB@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f2f5e7c4cc5a917e77a3d5a0c4353b702aa7307

Modified Files
--------------
src/backend/utils/activity/pgstat_relation.c | 108 ++++++++++++++-------------
src/backend/utils/adt/pgstatfuncs.c          |  24 +++---
src/include/pgstat.h                         |  42 ++++++++---
src/tools/pgindent/typedefs.list             |   1 +
4 files changed, 104 insertions(+), 71 deletions(-)



Message-ID: <E1x4Wq5-00000004EhQ-0EsC@gemulon.postgresql.org>
Permalink:  ../E1x4Wq5-00000004EhQ-0EsC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x4Wq5-00000004EhQ-0EsC@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: Split transaction data out of pgstats table counters
  In-Reply-To: <E1x4Wq5-00000004EhQ-0EsC@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox