From bc9dec707e2b12a6c6e7d1f654fbe41c8e5bbb65 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Tue, 18 Feb 2025 07:14:05 +0000
Subject: [PATCH v1 1/3] Add details in the pg_stat_io doc about the wal object

Adding details about writes, fsyncs, write_time and sync_time when linked
to the wal object. Same level of details as for wal_write, wal_sync, wal_write_time
and wal_sync_time in pg_stat_wal.
---
 doc/src/sgml/monitoring.sgml | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 100.0% doc/src/sgml/

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index 928a6eb64b0..2c61c0d1e50 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -2930,6 +2930,48 @@ description | Waiting for a newly initialized WAL file to reach durable storage
    writer</literal>.
   </para>
 
+  <para>
+   For the <literal>wal</literal> <structfield>object</structfield>:
+   <itemizedlist>
+    <listitem>
+     <para>
+      <structfield>writes</structfield> is the number of times WAL buffers were
+       written out to disk via <function>XLogWrite</function> request.
+       See <xref linkend="wal-configuration"/> for more information about the internal
+       WAL function <function>XLogWrite</function>.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <structfield>fsyncs</structfield> is the number of times WAL files were
+       synced to disk via <function>issue_xlog_fsync</function> request (if <xref linkend="guc-fsync"/>
+       is <literal>on</literal> and <xref linkend="guc-wal-sync-method"/> is either
+       <literal>fdatasync</literal>, <literal>fsync</literal> or <literal>fsync_writethrough</literal>,
+       otherwise zero). See <xref linkend="wal-configuration"/> for more information
+       about the internal WAL function <function>issue_xlog_fsync</function>.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <structfield>write_time</structfield> is the total amount of time spent writing
+       WAL buffers to disk via <function>XLogWrite</function> request.
+       This includes the sync time when <varname>wal_sync_method</varname>
+       is either <literal>open_datasync</literal> or <literal>open_sync</literal>.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <structfield>sync_time</structfield> is the total amount of time spent syncing
+       WAL files to disk via <function>issue_xlog_fsync</function> request (if
+       <varname>fsync</varname> is <literal>on</literal>,
+       and <varname>wal_sync_method</varname> is either <literal>fdatasync</literal>,
+       <literal>fsync</literal> or <literal>fsync_writethrough</literal>,
+       otherwise zero).
+     </para>
+    </listitem>
+   </itemizedlist>
+  </para>
+
   <para>
    <structname>pg_stat_io</structname> can be used to inform database tuning.
    For example:
-- 
2.34.1

