[PATCH v1 02/12] prune_xid-hist: create data structures
Renan Alves Fonseca <renanfonseca@gmail.com>
From: "Renan A. Fonseca" <renanfonseca@gmail.com>
To:
Date: 2025-05-20T11:35:39Z
Lists: pgsql-hackers
---
src/backend/access/heap/vacuumlazy.c | 1 +
src/include/pgstat.h | 21 ++++++++++++++++++++-
src/tools/pgindent/typedefs.list | 2 ++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index f28326bad09..8565f6dd215 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -355,6 +355,7 @@ typedef struct LVRelState
int64 live_tuples; /* # live tuples remaining */
int64 recently_dead_tuples; /* # dead, but not yet removable */
int64 missed_dead_tuples; /* # removable, but not removed */
+ PruneXidHistogramTransient prune_xid_hist;
/* State maintained by heap_vac_scan_next_block() */
BlockNumber current_block; /* last block returned */
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 378f2f2c2ba..d48f4742beb 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -111,6 +111,21 @@ typedef struct PgStat_BackendSubEntry
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES];
} PgStat_BackendSubEntry;
+#define PRUNE_XID_HIST_NBINS 5
+
+typedef struct PruneXidHistogram
+{
+ PgStat_Counter freqs[PRUNE_XID_HIST_NBINS];
+ TransactionId bounds[PRUNE_XID_HIST_NBINS];
+} PruneXidHistogram;
+
+typedef struct PruneXidHistogramTransient
+{
+ PgStat_Counter freqs[PRUNE_XID_HIST_NBINS];
+ PgStat_Counter neg_freq;
+ TransactionId bounds[PRUNE_XID_HIST_NBINS];
+} PruneXidHistogramTransient;
+
/* ----------
* PgStat_TableCounts The actual per-table counts kept by a backend
*
@@ -153,6 +168,8 @@ typedef struct PgStat_TableCounts
PgStat_Counter blocks_fetched;
PgStat_Counter blocks_hit;
+
+ PruneXidHistogramTransient prune_xid_hist;
} PgStat_TableCounts;
/* ----------
@@ -211,7 +228,7 @@ typedef struct PgStat_TableXactStatus
* ------------------------------------------------------------
*/
-#define PGSTAT_FILE_FORMAT_ID 0x01A5BCB7
+#define PGSTAT_FILE_FORMAT_ID 0x01A5BCB8
typedef struct PgStat_ArchiverStats
{
@@ -437,6 +454,8 @@ typedef struct PgStat_StatTabEntry
PgStat_Counter mod_since_analyze;
PgStat_Counter ins_since_vacuum;
+ PruneXidHistogram prune_xid_hist;
+
PgStat_Counter blocks_fetched;
PgStat_Counter blocks_hit;
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index e5879e00dff..02406a0776e 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2334,6 +2334,8 @@ PruneFreezeResult
PruneReason
PruneState
PruneStepResult
+PruneXidHistogram
+PruneXidHistogramTransient
PsqlScanCallbacks
PsqlScanQuoteType
PsqlScanResult
--
2.47.0
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
filename=v1-0003-prune_xid-hist-pgstat-prune_xid-histogram-interfa.patch