Re: pg_walinspect: add functions to locate and list WAL by time and LSN

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_walinspect: add functions to locate and list WAL by time and LSN
Date: 2026-11-23 23:57:41
Message-ID: CALj2ACUCnDyfH7kTmxj6Z5ng2=EPf5JHs+xUZVbF8_66mrWjtw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Nov 17, 2026 at 7:17 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> >> During HOW2026 in Jinan this April, a DBA talked to me that PG lacks an easy way to locate WAL files by time.
> >
> > I think using the existing pg_walinspect functions, one can look up
> > the times using the transaction commit/abort time from the description
> > column, starting from the last checkpoint's redo LSN till the current
> > flush LSN. Isn't this helpful? It takes a bit of time to do so, but
> > that should be fine.
>
> I'm afraid that's not easy.

I see the value here, and I'm not against the use case. I'm just not
yet convinced it needs new functions in pg_walinspect. Would something
like the attached work? For WAL in pg_wal, the SQL starts from the
oldest kept WAL or the last checkpoint record and reports the time,
LSN etc. And for WAL in the archive, pg_waldump can do something
similar with output filtering.

This example could go in the docs as an example, or on a wiki page
like the bloat queries. Returning the timestamp of the record as a
column would also help, so it doesn't have to be read out of the
description (i.e., less SQL).

That said, I will leave it here and wait for opinions from any
committer or other hackers. Thanks.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
nocfbot-timebased-wal-inspection.sh application/x-sh 2.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Prashant Chinnam 2026-11-24 00:09:58 Re: Hash aggregation shows only the last execution's stats for parallel workers
Previous Message Prashant Chinnam 2026-11-23 23:56:38 Re: [PATCH] pgcrypto: Fix sha-crypt rounds= values that do not fit in int (BUG #19743)