On Thu, Oct 23, 2025 at 06:36:01PM +0900, Shinya Kato wrote: > Okay, since I'm not strongly attached to this idea, I've removed the > 0003 patch for now.
The fact that we cannot access this information without a pg_waldump or a pg_walinspect, which may not be available, and can be expensive, is a deal-breaker for me.. Or we may not have a direct access to the WAL segments. Without the changes in instrument.c from patch 0002, patch 0001 that implements the basics would not work. So.. I have moved the changes of instrument.c to 0001, reordered the fields to be more consistent, did two bumps (catalog, stats file), simplified the docs, then applied the result. By the way, Kato-san, what do you think about the attached extra simplification? With the FPIs counted in bytes, I don't see much a point in passing around the number of FPIs generated from XLogRecordAssemble() to XLogInsertRecord() . -- Michael
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index d12798be3d80..9b6a042a607c 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -201,7 +201,6 @@ struct XLogReaderState;
extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata,
XLogRecPtr fpw_lsn,
uint8 flags,
- int num_fpi,
bool topxid_included);
extern void XLogFlush(XLogRecPtr record);
extern bool XLogBackgroundFlush(void);
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index eceab3412558..bc1627286539 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -748,7 +748,6 @@ XLogRecPtr
XLogInsertRecord(XLogRecData *rdata,
XLogRecPtr fpw_lsn,
uint8 flags,
- int num_fpi,
bool topxid_included)
{
XLogCtlInsert *Insert = &XLogCtl->Insert;
@@ -1080,7 +1079,6 @@ XLogInsertRecord(XLogRecData *rdata,
{
pgWalUsage.wal_bytes += rechdr->xl_tot_len;
pgWalUsage.wal_records++;
- pgWalUsage.wal_fpi += num_fpi;
/* Required for the flush of pending stats WAL data */
pgstat_report_fixed = true;
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index b3abf386f801..6b47c13a2c25 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -138,7 +138,7 @@ static MemoryContext xloginsert_cxt;
static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info,
XLogRecPtr RedoRecPtr, bool doPageWrites,
- XLogRecPtr *fpw_lsn, int *num_fpi,
+ XLogRecPtr *fpw_lsn,
bool *topxid_included);
static bool XLogCompressBackupBlock(const PageData *page, uint16 hole_offset,
uint16 hole_length, void *dest, uint16 *dlen);
@@ -511,7 +511,6 @@ XLogInsert(RmgrId rmid, uint8 info)
bool topxid_included = false;
XLogRecPtr fpw_lsn;
XLogRecData *rdt;
- int num_fpi = 0;
/*
* Get values needed to decide whether to do full-page writes. Since
@@ -521,9 +520,9 @@ XLogInsert(RmgrId rmid, uint8 info)
GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
- &fpw_lsn, &num_fpi, &topxid_included);
+ &fpw_lsn, &topxid_included);
- EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi,
+ EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags,
topxid_included);
} while (EndPos == InvalidXLogRecPtr);
@@ -562,7 +561,7 @@ XLogSimpleInsertInt64(RmgrId rmid, uint8 info, int64 value)
static XLogRecData *
XLogRecordAssemble(RmgrId rmid, uint8 info,
XLogRecPtr RedoRecPtr, bool doPageWrites,
- XLogRecPtr *fpw_lsn, int *num_fpi, bool *topxid_included)
+ XLogRecPtr *fpw_lsn, bool *topxid_included)
{
XLogRecData *rdt;
uint64 total_len = 0;
@@ -715,9 +714,6 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
*/
bkpb.fork_flags |= BKPBLOCK_HAS_IMAGE;
- /* Report a full page image constructed for the WAL record */
- *num_fpi += 1;
-
/*
* Construct XLogRecData entries for the page content.
*/
@@ -799,6 +795,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
total_len += bimg.length;
+ /* Report a full page image constructed for the WAL record */
+ pgWalUsage.wal_fpi += 1;
/* Track the WAL full page images in bytes */
pgWalUsage.wal_fpi_bytes += bimg.length;
pgstat_report_fixed = true;
signature.asc
Description: PGP signature
