Re: EXPLAIN: showing ReadStream / prefetch stats

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Andres Freund <andres(at)anarazel(dot)de>, Lukas Fittl <lukas(at)fittl(dot)com>
Cc: Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: EXPLAIN: showing ReadStream / prefetch stats
Date: 2026-03-18 22:41:13
Message-ID: bf1d4799-e2fd-464c-96ff-dc448f021b1e@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Here's a v3 of the patch, adopting the idea of passing the data through
a field in the scan descriptor. I've kept it broken into multiple
smaller pieces 0002-0006 to show the incremental changes, but in the end
this should be all merged.

0001 - a prerequisite patch

0002 - v2 of the patch

0003 - basic cleanup / helpers to reduce code duplication, various
smaller fixes and improvements, ...

0004 - changes the design to use a new field in TableScanDesc

0005 - minor cleanup of 0004

0006 - support for TidRangeScan (the last scan using ReadStream),
requires changes similar to SeqScan in v2

Overall, I think it looks reasonable. There are probably ways to
simplify it further (e.g. by introducing a new read_stream_begin_
helper, so that it's not necessary to update every caller of
read_stream_begin_relation by adding a NULL argument).

The 0003 also changes the EXPLAIN to enable IO by default, just like we
do for BUFFERS. It seems like a reasonable precedent to me.

0004 reworks the tracking to use a field in TableScanDesc, instead of
adding a table AM callback. I agree it seems simpler / less disruptive.

0005 is a minor cleanup for 0004

0006 adds EXPLAIN support for TidRangeScan, similarly to how 0002 adds
support for SeqScan (but that still uses the TAM interface)

regards

--
Tomas Vondra

Attachment Content-Type Size
v3-0001-bufmgr-Return-whether-WaitReadBuffers-needed-to-w.patch text/x-patch 2.8 KB
v3-0002-explain-show-prefetch-stats-in-EXPLAIN-ANALYZE-VE.patch text/x-patch 35.1 KB
v3-0003-cleanup-and-simplification.patch text/x-patch 62.9 KB
v3-0004-store-the-IO-stats-in-scan-descriptor.patch text/x-patch 24.3 KB
v3-0005-get-rid-of-TableScanStats-Data.patch text/x-patch 5.3 KB
v3-0006-show-prefetch-stats-for-TidRangeScan.patch text/x-patch 9.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-18 22:41:20 Re: remove bits* types
Previous Message Robert Haas 2026-03-18 22:34:29 Re: pg_plan_advice