pgsql: Split transaction data out of pgstats table counters

Started by Michael Paquier2 months ago1 messagescommitters
Jump to latest
#1Michael Paquier
michael@paquier.xyz

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: /messages/by-id/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(-)