Re: EXPLAIN: showing ReadStream / prefetch stats
Tomas Vondra <tomas@vondra.me>
From: Tomas Vondra <tomas@vondra.me>
To: Andres Freund <andres@anarazel.de>
Cc: Lukas Fittl <lukas@fittl.com>,
Melanie Plageman <melanieplageman@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-03T19:01:05Z
Lists: pgsql-hackers
Attachments
- v8-0001-switch-explain-to-unaligned-for-json-xml-yaml.patch (text/x-patch) patch v8-0001
- v8-0002-Show-Bitmap-Heap-Scan-stats-for-non-parallel-awar.patch (text/x-patch) patch v8-0002
- v8-0003-explain-show-prefetch-stats-in-EXPLAIN-ANALYZE.patch (text/x-patch) patch v8-0003
- v8-0004-show-prefetch-stats-for-SeqScan.patch (text/x-patch) patch v8-0004
- v8-0005-show-prefetch-stats-for-TidRangeScan.patch (text/x-patch) patch v8-0005
- test-bitmapscan.sql (application/sql)
- test-seqscan.sql (application/sql)
- test-tidrangescan.sql (application/sql)
Here's v8, with a couple improvements: 1) stats for non-parallel-aware scans It correctly shows stats for scans that are not parallel-aware. I'd argue for BitmapHeapScan this is a live bug in 5a1e6df3b84c, so I kept it in a separate commit 0002. It probably should be backpatched to PG18, even if no one complained about it. For SeqScan/TidRangeScan I've merged the changes into 0004 and 0005. I have to admit I'm not a huge fan of the changes required to fix this. The logic with all these instument/parallel_aware conditions seems much less readable to me, but I don't know how else to do this. The approach is copied from nodeIndexscan.c, which already did that in 0fbceae841cb. 2) worker stats While working on fixing the BHS, I realized it prints the worker stats using ExplainOpenWorker/ExplainCloseWorker, which puts-aside the worker stats. Which is better than the original approach - it does not require a separate function (with a lot of duplication). The bad thing is this gives us even less control over the order of items in the explain output. I'm mostly happy with this, except for the decreased readability due to the various checks of instrument/parallel_aware. I'm also attaching SQL scripts for the three scans, with plans that include them in places with parallel_aware=false. All plans should have the relevant explain stats for all the scans. regards -- 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