Showing "Table Block Fetches" in EXPLAIN ANALYZE for index-only scans

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Showing "Table Block Fetches" in EXPLAIN ANALYZE for index-only scans
Date: 2026-10-15 19:12:19
Message-ID: CAH2-Wz=vLkCGiLs-9kB0ubZAUyYnrMu_GN78TJ=u2sVncJeanA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Attached patch teaches EXPLAIN ANALYZE to show "Table Block Fetches"
instead of "Heap Fetches" when reporting on an index-only scan node. I
believe that users will find this information more useful and
relevant: it describes the exact physical cost of *not* having the
relevant heap pages marked as all-visible in the visibility map,
without bringing tuples into it.

"Table Block Fetches" is exactly the number of times an index-only
scan had to switch to a new heap block. I'm not fussed about the name
we use for this, though I think that avoiding references to heap is
desirable. This information is table AM agnostic, at least in theory.

I lean towards not showing anything about IoS heap tuple fetches in
EXPLAIN ANALYZE, which is how it's done in this V1. But if there's a
consensus in favor of keeping it, I can easily produce a revision that
counts and reports on both things.

This approach became much easier following my recent commit ddce1da5,
which added a new slot-based table AM index scan interface. That
commit put the responsibility for maintaining the scan's "Heap
Fetches" counter into heapam. I suspect that the current approach
might be as much a consequence of how awkward it would have been to
teach nodeIndexonlyscan.c to do things this way as anything else.

--
Peter Geoghegan

Attachment Content-Type Size
v1-0001-Show-block-not-tuple-fetches-in-EXPLAIN-ANALYZE.patch application/octet-stream 24.8 KB

Browse pgsql-hackers by date

  From Date Subject
Previous Message Sami Imseih 2026-10-15 19:03:21 Re: [PATCH] Doc fix for autovacuum_max_parallel_workers