Re: [Proposal] pg_stat_wal_records – per-record-type WAL generation statistics - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [Proposal] pg_stat_wal_records – per-record-type WAL generation statistics
Date
Msg-id acXylU7iQ4P_YbGD@paquier.xyz
Whole thread Raw
In response to [Proposal] pg_stat_wal_records – per-record-type WAL generation statistics  (SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>)
List pgsql-hackers
On Thu, Mar 26, 2026 at 05:29:25PM -0700, SATYANARAYANA NARLAPURAM wrote:
> Postgre already has pg_stat_wal for aggregate WAL volume (bytes, full-page
> images, buffers), and pg_walinspect (superuser access required) for
> post-hoc forensic analysis of individual WAL segments. But I don't see a
> lightweight, observability tool that answers in real time which record
> types are responsible for the WAL. Additionally, pg_walinspect runs against
> on-disk WAL files, which is expensive. This view will be useful for
> monitoring systems to poll cheaply.
>
> *Use cases:*
> WAL volume investigation: see which record types dominate WAL generation in
> real time without touching disk.
> Monitoring integration: Prometheus/Grafana can poll the view to track WAL
> composition over time and alert on anomalies.
> Replication tuning: identify whether WAL volume is dominated by data
> changes, index maintenance, FPIs, or vacuum activity to guide tuning.
> Extension debugging: custom WAL resource managers get visibility
> automatically.

Why is it useful to have access to this information in live for
monitoring purposes, divided by RMGR?  What do you define as an
anomaly in this context and what can be changed on the server side to
get out of an anomaly, based on the definition you would give to it?

The current WAL and IO stats are directly useful because they provide
numbers about flush, read and write quantity and timings.  These are
useful metrics for benchmarking.

This proposal only informs about the number of records, and we have a
various number of record types that have a variable length, that can
influence the distribution of the data written on disk.

As a whole, I am doubtful that this information is worth counting in
live, eating a stats kind ID.  One could also implement a background
worker that provides more advanced aggregate stats outside the WAL
insert path, with a custom stats kind.  No need to have that into
core, especially if the code that increments the stats eats more and
more cycles.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Patch for migration of the pg_commit_ts directory
Next
From: Yugo Nagata
Date:
Subject: Re: Add comments about fire_triggers argument in ri_triggers.c