Re: EXPLAIN: showing ReadStream / prefetch stats

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Melanie Plageman <melanieplageman(at)gmail(dot)com>, Lukas Fittl <lukas(at)fittl(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: EXPLAIN: showing ReadStream / prefetch stats
Date: 2026-04-07 18:12:37
Message-ID: dtrtzpme6akzxldzug5emrjhukcnp2sfjuikynyypgzpbprn2y@k47nuuueldgr
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-04-07 18:13:18 +0200, Tomas Vondra wrote:
> On 4/7/26 17:27, Melanie Plageman wrote:
> > I took another look at just 0002 just to double-check the read stream
> > counters. It seems fine.
> > Perhaps we should free the TableScanInstrumentation in heap_endscan().
> > It isn't that important of a leak, but the other things palloc'd in
> > heap_beginscan() are freed.
> >
>
> Good point, will fix.
>
> > I also wondered if it is clear without a comment why we don't count a
> > wait when READ_BUFFERS_SYNCHRONOUSLY sets needed_wait (which we added
> > to make sure distance ramps up). I think it's fine; I'm just musing.
> >
>
> I believe this is actually a bug, the read_stream_count_wait() should be
> after the block checking for READ_BUFFERS_SYNCHRONOUSLY. I recall Andres
> mentioned this in one of this reviews, but I either forgot to address
> that, or it got lost then transferring this between this thread and the
> index prefetching one.

Yea, I think it's actually somewhat important that those will be counted as
waits, since they *are* blocking reads. It's just that the blocking read
happends during the start of the IO, so we don't have to wait in
WaitReadBuffers(). You'd otherwise severely undercounting reads in cases where
the distance ramps up and down a lot

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-04-07 18:19:51 Re: Add errdetail() with PID and UID about source of termination signal
Previous Message Sami Imseih 2026-04-07 18:02:49 Re: test_autovacuum/001_parallel_autovacuum is broken