Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6Btc-0042f1-1c for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 18:27:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6Bta-00BFSn-0O for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 18:26:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6BtZ-00BFSe-2J for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 18:26:58 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w6BtY-00000001MXE-0SKD for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 18:26:57 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-604f1bfed92so1392658137.0 for ; Fri, 27 Mar 2026 11:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774636015; cv=none; d=google.com; s=arc-20240605; b=FuFEy4fz5D3Fj+CJ3ByYIjKzDW3lDlnovwz+pyAp8IXm4PQr4KCtWtjhRFYo2RMyVb JM84pcAm2SQGW4VF5/NwX4VYBjdEubCVj6688+ynqYm0dDEYYd64Nu3We21MRyiguRo0 UM76EQHWD+oh37olh1Zl5AG/M0I9WuR1ztCyc7zZBs902/iZ6q50K4ZZtvROZgZtOJlm hNDLutfluF3urplTGC+M1OUYPwMD4YCvecZZdQJ9nolGw6AE1sQyJxa2BKw54VOwuh4R P1DyJBVgzFuizCApE4ztTTk1xQ4ILDZfb7JPluZ6PWlRGJ+vjjTt8JIRCOQGlZsBVwi/ EhJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=7uZoByL42kyMBLRTRLO/wTQ9yM+KeGsZtFIUFn5U+CE=; fh=vfv9FWGnrZSJ+I9MmM6NQrdrLwIFNjm0FOncyf2qe8E=; b=ELGc8gsrlDeDAwChzx17ftrNr5m3tgMNXnGaJ7KdIdVvyPZb5tZjR5GRYIHIiiVBrN x2PC0/yAAQEgL6xsc5MUf59M7W1+cEtBCJYa8vNH6ma0PZzQ1SxN3m9Xh2i+Z6fYkj+I Kr2OZ01Vk5RrThR9puad+sVLuUfLj19RJiyGE/jUDUX3c1UezuvQw9USSSRADI86gHFa fsJbsYZuC5N/5gHqvN+uLpGmONApb7X4Br5dBlJgxmnpmndNJ+zIcRkiQYq/DXy+2nyz 8fAxxT6pKfLD9cQXgaQ9I0o94eek7Gq3uxDLwztOGWWE7iqCkezduTseLpDYdR13idnO ez5A==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774636015; x=1775240815; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7uZoByL42kyMBLRTRLO/wTQ9yM+KeGsZtFIUFn5U+CE=; b=VCZVzku6bUg/yPdNum/qtbzIvADh/3PHWK9VFEUpatYmnNRVE3iqkiGSBzZ1JI1HWM 464r/4UawQeYRATkS1fi/O5fEW7W4pjKGkEXqwmJ+V0W5kNf/FkdVyjqiw2WclcQgxtp HZ7MMYUdZ7Jb4+eJPwVegMFibkVthKD8H6qSRxYmUhRRA3uWvS9j6P7Q7lFAHD+IXCZx 0Wr3GqohBaLOySI6WVuLnzMVe1tDa+IptdlcfglC3PtAHNACdAKyEyKR1agrqRyeQHP3 q5DXeLYrV7M9rtoniyVjvHGXfXLMs7BVLgaU04wVguuKBIB440iqdZ53duxZc4QfRyiy qOYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774636015; x=1775240815; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7uZoByL42kyMBLRTRLO/wTQ9yM+KeGsZtFIUFn5U+CE=; b=D5jBH9G1N/plMDKK5NHnQXc3x7rfWYALHBaY23gqDWq+hhtMnti4IWlsW8E1Pqtnhp 2/7wBmc6a+OAqAmvkSR2DuzgRk/Qr/8QJQRClhdOWo3YVVjG+u24gFRWr8dLhY4uyZp8 NRC61Rk8o8djVWXvX3Tx7BWEdKmE5fA4m0GeHTPc3ljEacR7KRvYIyQIdm+W2wkBWDIz kao3iWccR0XPVFGHKpuD87q7JXpCU+abRq+SLhQyerSVKjKEZigK02+1K6zswYJLTPoU F/DLizjGKbv7m3VhEfxyIr3QtAnyZO44Hv6xHoEtUz3RUG5JrDIUfotarWPsPVxtFZsA 5dCg== X-Gm-Message-State: AOJu0YxKo86U1BdGHxDQulPOT2f628Xutdqjb4Ppb6RIyDNQuxS/TpUz BAxmwoe9bg/JvU11i0GHKMMaoJ/S4wD51FF3vV+2dtXsZjBrA/Ze96ZRfisE9l9WDOhHe0N8Z6z y9YeK6/GjzniBmZa+WuzUsQG9FK7Z38xrLB2n X-Gm-Gg: ATEYQzwG49OHY9byTq+IL5FL8r7OcyJBni27UALPqjJixXqgdQQ3YRv1TuWUzFoqVWa 1AiP/S0bggyFEl1ts8nWi178+XVX3KyOyiGlDSKkZmS3a/TlkUTmnxC+oQa8ofSlCmCoRowyscL g+igcZxJi9t8ZVwVdiJS5laEZ82oyDd0ZPtBLdgu0yrzK7a6F822hjd3ctKqO+fBXgn7Fh8jOMY AMDQv+EPgrOGNgGojGGlAYD0GWf8pDe4xotOoubLi1i1WEoOiCj+WE4BMAl3/oOM97bipJrJSWH f4XnOUM= X-Received: by 2002:a05:6102:534a:b0:602:a80a:4d58 with SMTP id ada2fe7eead31-604f92e5eb9mr1783690137.26.1774636015043; Fri, 27 Mar 2026 11:26:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: SATYANARAYANA NARLAPURAM Date: Fri, 27 Mar 2026 11:26:43 -0700 X-Gm-Features: AQROBzB1jbd1cqIZnf3iDztzADQtLSj1GAIfVCqH-f1-DqxnuJJ6HinE3gknYQs Message-ID: Subject: =?UTF-8?Q?Re=3A_=5BProposal=5D_pg=5Fstat=5Fwal=5Frecords_=E2=80=93_per=2Drecord=2Dty?= =?UTF-8?Q?pe_WAL_generation_statistics?= To: Michael Paquier Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000484a99064e05a591" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000484a99064e05a591 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Michael, Thank you for your feedback! On Thu, Mar 26, 2026 at 7:59=E2=80=AFPM Michael Paquier wrote: > 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 generatio= n > in > > real time without touching disk. > > Monitoring integration: Prometheus/Grafana can poll the view to track W= AL > > 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? Per-RMGR breakdown is essentially a real-time X-ray of what the database is actually doing. Existing view help us understand what queries were submitted, but what physical operations resulted from them can be seen with this view. > 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? > A few examples, HOT ratio dropped, BTree page splits, some app adding logical decoding messages, GIN generates more WAL than the corresponding heap modifications, high lock counts etc. > > 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. > yeah, that was a downside, didn't add sizes to keep the overhead less. 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. Your argument makes sense to me, I was a bit hesitant on writing a background worker because of the potential side effects of tailin= g the WAL. Let me try a different approach by implementing an ondemand sniffing of the WAL, which can be implemented as an extension without changes to core. Do you have thoughts on making it a contrib module or modify existing pg_walinspect to accommodate these requirements? Thanks, Satya --000000000000484a99064e05a591 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi=C2=A0 Michael,

Thank you for your feedback!

On Thu, Mar 26, 2026= at 7:59=E2=80=AFPM Michael Paquier <michael@paquier.xyz> wrote:
On Thu, Mar 26, 2026 at 05:29:25PM -0700, SATYANARAY= ANA 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 ag= ainst
> 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 generati= on 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.<= br> > 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?=C2=A0
=C2=A0
Per-RMGR breakdown is essentially a real-time X-ray of what the dat= abase
is actually doing. Existing view help us understand what qu= eries were submitted,=C2=A0
but what physical operations resulted= from them can be seen with this view.

=C2= =A0
What do you defi= ne 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?

A few examples,=C2=A0HOT ratio dropped, BTree= page splits, some app adding=C2=A0
logical decoding messages, GI= N generates more WAL than the corresponding=C2=A0
heap modificati= ons, high lock counts etc.
=C2=A0

The current WAL and IO stats are directly useful because they provide
numbers about flush, read and write quantity and timings.=C2=A0 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.

yeah, that was a downside, didn't add sizes to keep th= e overhead less.

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

Your argument makes sense to m= e, I was a bit hesitant on
writing a background worker because of= the potential side effects of tailing
=C2=A0the WAL. Let me try = a different approach by implementing an ondemand
sniffing of the = WAL, which can be implemented as an extension without
changes to = core. Do you have thoughts on making it a contrib module or
modif= y existing pg_walinspect to accommodate=C2=A0these requirements?
=
Thanks,
Satya
--000000000000484a99064e05a591--