Re: EXPLAIN: showing ReadStream / prefetch stats

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Lukas Fittl <lukas@fittl.com>
Cc: Tomas Vondra <tomas@vondra.me>, Melanie Plageman <melanieplageman@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-07T15:09:40Z
Lists: pgsql-hackers
Hi,

On 2026-04-07 01:00:28 -0700, Lukas Fittl wrote:
> Btw, in that same test, when I re-run I get Prefetch but not I/O -- why is that?
> 
>  Seq Scan on organizations  (cost=0.00..7.42 rows=1 width=483) (actual
> time=0.034..0.042 rows=1.00 loops=1)
>    Filter: (slug = 'pganalyze'::text)
>    Rows Removed by Filter: 113
>    Prefetch: avg=1.00 max=1 capacity=94
>    Buffers: shared hit=6
> 
> (if its all buffers hit, why are there any prefetches at all?)

It's not really prefetching, which is visible as the distance being 1.  The
read stream is created at the start of the scan, not at the first miss.

Greetings,

Andres Freund



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. bufmgr: Return whether WaitReadBuffers() needed to wait