pgsql: Report pages read from WAL buffers in pg_stat_io.hits

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Report pages read from WAL buffers in pg_stat_io.hits
Date: 2026-10-15 23:09:28
Message-ID: E1xHUZk-00000001nET-2AYP@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Report pages read from WAL buffers in pg_stat_io.hits

Callers of WALReadFromBuffers() read data from the WAL buffers
(currently only WAL senders). This commit makes now available the
number of pages read from the WAL uffers in pg_stat_io.hits under object
"wal" and context "normal".

A read from a WAL file is counted in pg_stat_io.reads and read_bytes.
This new information can be useful for the tuning of wal_buffers, where
the number of hits matches with the number of pages found as available
in the buffers.

Note that WALReadFromBuffers() may be called for an amount of data worth
less than one WAL page, and that a partial page read is counted as one
hit.

Author: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/CALj2ACVfF2Uj9NoFy-5m98HNtjHpuD17EDE9twVeJng-jTAe7A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/856a6594d86e4a7c0e9490253912af3f6159802f

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 8 +++++++-
src/backend/access/transam/xlog.c | 6 ++++++
src/backend/utils/activity/pgstat_io.c | 9 ++++++---
src/test/recovery/t/001_stream_rep.pl | 9 +++++----
4 files changed, 24 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-10-16 03:49:33 pgsql: Fix Parallel TID Range Scan rescans with a different TID range
Previous Message Masahiko Sawada 2026-10-15 21:09:36 pgsql: Avoid dangling shared memory pointers in parallel vacuum.