public inbox for [email protected]
help / color / mirror / Atom feedFrom: Fujii Masao <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Restrict data checksums entries in pg_stat_io
Date: Fri, 10 Jul 2026 12:13:37 +0900
Message-ID: <CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com> (raw)
Hi,
While reviewing the data checksums docs at [1], I found that the data checksums
launcher and workers are exposed in pg_stat_io with the same broad set of
object/context combinations as general background workers.
However, several of those entries can never accumulate I/O statistics.
For example, as far as I understand correctly, the launcher never processes
relations itself, and the workers neither operate on temporary relations nor
use the bulkread or bulkwrite contexts. So I think it would be better to
restrict the reported entries to those that the data checksums processes
can actually use.
The attached patch teaches pgstat_tracks_io_object() and pgstat_tracks_io_op()
about the actual I/O paths used by these processes. After the patch,
pg_stat_io includes only:
- data checksums launcher: relation/normal, wal/init, wal/normal
- data checksums worker: relation/normal, relation/vacuum, wal/init, wal/normal
The patch also excludes WAL reads for both processes, since they emit
WAL records but never read WAL.
Thoughts?
Regards,
[1] https://postgr.es/m/CAHGQGwFsBjQs2fv7b72hxzGV_fJMh6LAg4E83pNfDOu1jVgWCA@mail.gmail.com
--
Fujii Masao
Attachments:
[application/octet-stream] v1-0001-Restrict-pg_stat_io-entries-for-data-checksum-pro.patch (3.7K, ../CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com/2-v1-0001-Restrict-pg_stat_io-entries-for-data-checksum-pro.patch)
download | inline diff:
From 103a54882c40304958b4a360e0ac07f6b70b8fe1 Mon Sep 17 00:00:00 2001
From: Fujii Masao <[email protected]>
Date: Fri, 10 Jul 2026 10:54:46 +0900
Subject: [PATCH v1] Restrict pg_stat_io entries for data checksum processes
The data checksums launcher and workers were exposed in pg_stat_io
with the same broad set of object/context combinations as general
background workers. However, many of those entries can never accumulate
I/O statistics for these processes, such as bulkread, bulkwrite,
relation init, and temporary relation entries.
Teach pgstat_tracks_io_object() and pgstat_tracks_io_op() about the
actual I/O performed by the data checksum processes. Keep the entries
needed for catalog scans, worker relation processing with a vacuum
access strategy, and WAL writes and initialization, while excluding WAL
reads and other object/context combinations that can never be used.
---
src/backend/utils/activity/pgstat_io.c | 31 ++++++++++++++++++++++++++
src/test/regress/expected/stats.out | 11 +--------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c
index 38bae7b15d2..4f862c961c5 100644
--- a/src/backend/utils/activity/pgstat_io.c
+++ b/src/backend/utils/activity/pgstat_io.c
@@ -464,6 +464,35 @@ pgstat_tracks_io_object(BackendType bktype, IOObject io_object,
io_context == IOCONTEXT_BULKWRITE)
return false;
+ /*
+ * The data checksums launcher only scans catalogs and emits WAL records
+ * for checksum state changes.
+ */
+ if (bktype == B_DATACHECKSUMSWORKER_LAUNCHER)
+ {
+ if (io_object == IOOBJECT_WAL ||
+ (io_object == IOOBJECT_RELATION &&
+ io_context == IOCONTEXT_NORMAL))
+ return true;
+
+ return false;
+ }
+
+ /*
+ * The worker also scans catalogs, then processes relations using a vacuum
+ * access strategy.
+ */
+ if (bktype == B_DATACHECKSUMSWORKER_WORKER)
+ {
+ if (io_object == IOOBJECT_WAL ||
+ (io_object == IOOBJECT_RELATION &&
+ (io_context == IOCONTEXT_NORMAL ||
+ io_context == IOCONTEXT_VACUUM)))
+ return true;
+
+ return false;
+ }
+
return true;
}
@@ -507,6 +536,8 @@ pgstat_tracks_io_op(BackendType bktype, IOObject io_object,
if (io_object == IOOBJECT_WAL && io_op == IOOP_READ &&
(bktype == B_WAL_RECEIVER || bktype == B_BG_WRITER ||
bktype == B_AUTOVAC_LAUNCHER || bktype == B_AUTOVAC_WORKER ||
+ bktype == B_DATACHECKSUMSWORKER_LAUNCHER ||
+ bktype == B_DATACHECKSUMSWORKER_WORKER ||
bktype == B_WAL_WRITER))
return false;
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index 03cbc1cdef5..ccb716c7c10 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -51,20 +51,11 @@ client backend|relation|vacuum
client backend|temp relation|normal
client backend|wal|init
client backend|wal|normal
-datachecksums launcher|relation|bulkread
-datachecksums launcher|relation|bulkwrite
-datachecksums launcher|relation|init
datachecksums launcher|relation|normal
-datachecksums launcher|relation|vacuum
-datachecksums launcher|temp relation|normal
datachecksums launcher|wal|init
datachecksums launcher|wal|normal
-datachecksums worker|relation|bulkread
-datachecksums worker|relation|bulkwrite
-datachecksums worker|relation|init
datachecksums worker|relation|normal
datachecksums worker|relation|vacuum
-datachecksums worker|temp relation|normal
datachecksums worker|wal|init
datachecksums worker|wal|normal
io worker|relation|bulkread
@@ -111,7 +102,7 @@ walsummarizer|wal|init
walsummarizer|wal|normal
walwriter|wal|init
walwriter|wal|normal
-(95 rows)
+(86 rows)
\a
-- List of registered statistics kinds.
SELECT id, name, fixed_amount,
--
2.55.0
view thread (3+ messages)
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: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Restrict data checksums entries in pg_stat_io
In-Reply-To: <CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com>
* 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