Re: EXPLAIN: showing ReadStream / prefetch stats
Tomas Vondra <tomas@vondra.me>
From: Tomas Vondra <tomas@vondra.me>
To: Lukas Fittl <lukas@fittl.com>
Cc: Andres Freund <andres@anarazel.de>,
Melanie Plageman <melanieplageman@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-26T00:35:01Z
Lists: pgsql-hackers
Attachments
- v5-0006-adjust-explain-output.patch (text/x-patch) patch v5-0006
- v5-0005-show-prefetch-stats-for-TidRangeScan.patch (text/x-patch) patch v5-0005
- v5-0004-show-prefetch-stats-for-SeqScan.patch (text/x-patch) patch v5-0004
- v5-0003-explain-show-prefetch-stats-in-EXPLAIN-ANALYZE.patch (text/x-patch) patch v5-0003
- v5-0002-Thread-flags-through-begin-scan-APIs.patch (text/x-patch) patch v5-0002
- v5-0001-bufmgr-Return-whether-WaitReadBuffers-needed-to-w.patch (text/x-patch) patch v5-0001
Hi, Here's a slightly improved v5, with a couple minor changes over v4. Patches 0001 and 0002 are prerequisites from other threads. 0001 was already included in v4. 0002 is new and comes from [1], and it adds "flags" to TAM beginscan() methods. This allows 0003 to pass a new SO_SCAN_INSTRUMENT flag, so that e.g. heap_beginscan() can initialize the instrumentation only when executed in EXPLAIN ANALYZE. In v4 it had to be done every time, which did not seem quite great. This mimics what we do for index scans in the index prefetching, which only allocates the instrumentation when needed. 0004 and 0005 are adjusted to do this for SeqScan and TidRangeScans too. 0006 is a minor adjustment of the explain output, based on the earlier discussion about non-text formats. It removes the explain groups (to not add nested output), and instead makes the labels more descriptive. It also prints the items every time, even with io_count==0. The last change is that I added the number of I/Os, instead of printing just the number of stalls and average I/O size. Without the count it seemed a bit difficult to interpret. It might be possible to deduce some of this from buffers reads, but I found it a bit unclear. 0006 should be split and merged into the earlier parts, I mostly kept it to make those changes obvious. regards https://www.postgresql.org/message-id/itvgqc6vncbjsjfmrptfvkkeg5vqzhalaguya2z77t6c6ctpc3%40wsdrgbn4bxaa -- Tomas Vondra
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
bufmgr: Return whether WaitReadBuffers() needed to wait
- 513374a47a71 19 (unreleased) landed