Re: log XLogPrefetch stats at end of recovery

From: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, Lakshmi N <lakshmin(dot)jhs(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: log XLogPrefetch stats at end of recovery
Date: 2026-11-30 08:24:04
Message-ID: CAKZiRmw0yKkkb+cOf4UryxJFnqdN68V3CSOrOqhB26iJFGpUbQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 19, 2026 at 1:17 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Thu, Nov 12, 2026 at 5:58 AM Bharath Rupireddy
> <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> > I think it is RfC. Thoughts?
>
> I'm not sure how useful it is to log these statistics even though
> they are already available in pg_stat_recovery_prefetch.
>
> Currently, the counters in pg_stat_recovery_prefetch are not saved
> and restored by pgstat, so they are lost even across a clean restart.
> So, if the goal of this patch is to preserve them for later analysis,
> logging them could be useful.
>
> But, making these statistics persistent was already discussed when
> recovery prefetch was introduced [1]. If we eventually implement that
> in the future, the statistics could be queried from the view after
> a clean restart. So I'm wondering what additional value the log message
> would provide in that case.... Sorry if I'm missing something.

Hi Fujii,

I think logging the information would be helpful for two reasons mainly:

1. For analysis of the past events - sometimes support cases/coworkers have
only access to the log and without ability to fetch from view on demand.
As this is recovery thingy, thoses cluster node can end-up being bounced
hard (frequent failover/switchovers). Then sometime people later ask the
question why the recovery took so long or what it was different this time?
(having this in log would help answering such questions)

2. By logging it always, devs could get some insight from real world systems
how the WAL stream looks like there (in terms of xlogprefetcher capable
of dealing with that). I'm thinking of this as some 'feature usage
analytics' that would helps further spot some issues potentially. Also such
measures could be used to tweak m_io_c and wal_decode_buffer_size.

However, my bigger problem now is that the patch today misses to calculate
actionable metrics (e.g. what was the average io_depth or block_distance over
time)? So if avg io_depth and/or avg wal_distance are out, I don't think
it's all that useful.

Also Thomas mentioned "true-AIO-for-recovery" [1] potentially one day, so
whatever would be logged here today, would have to stick and cover future
implementation too, right?

-J.

[1] - https://www.postgresql.org/message-id/CA%2BhUKGJpKFpAB-du_m3zzZmRjdg_V65TsLj_DDMSJnzikWDG7w%40mail.gmail.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2026-11-30 08:50:36 NOT-IN to ANTI-JOIN conversation changes query result
Previous Message Xuneng Zhou 2026-11-30 08:04:49 Re: Small WAL replay perf improvements (smgropen()+reduce membarriers for LSN waiters)