postgresql/src/include/access
Tomas Vondra 681daed931 Add EXPLAIN (IO) infrastructure with BitmapHeapScan support
Allows collecting details about AIO / prefetch for scan nodes backed by
a ReadStream. This may be enabled by a new "IO" option in EXPLAIN, and
it shows information about the prefetch distance and I/O requests.

As of this commit this applies only to BitmapHeapScan, because that's
the only scan node using a ReadStream and collecting instrumentation
from workers in a parallel query. Support for SeqScan and TidRangeScan,
the other scan nodes using ReadStream, will be added in subsequent
commits.

The stats are collected only when required by EXPLAIN ANALYZE, with the
IO option (disabled by default). The amount of collected statistics is
very limited, but we don't want to clutter EXPLAIN with too much data.

The IOStats struct is stored in the scan descriptor as a field, next to
other fields used by table AMs. A pointer to the field is passed to the
ReadStream, and updated directly.

It's the responsibility of the table AM to allocate the struct (e.g. in
ambeginscan) whenever the flag SO_SCAN_INSTRUMENT flag is passed to the
scan, so that the executor and ReadStream has access to it.

The collected stats are designed for ReadStream, but are meant to be
reasonably generic in case a TAM manages I/Os in different ways.

Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me
2026-04-07 22:33:34 +02:00
..
amapi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
amvalidate.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
attmap.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
attnum.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_internal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_page.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_pageops.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_revmap.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_tuple.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
brin_xlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
bufmask.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
clog.h Convert SLRUs to use the new shmem allocation functions 2026-04-06 02:13:02 +03:00
cmptype.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
commit_ts.h Convert SLRUs to use the new shmem allocation functions 2026-04-06 02:13:02 +03:00
detoast.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
genam.h Allocate separate DSM chunk for parallel Index[Only]Scan instrumentation 2026-04-06 19:10:19 -04:00
generic_xlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
gin.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
gin_private.h Optimize sort and deduplication in ginExtractEntries() 2026-04-07 13:26:39 +03:00
gin_tuple.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
ginblock.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
ginxlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
gist.h Do not lock in BufferGetLSNAtomic() on archs with 8 byte atomic reads 2026-03-11 19:46:08 +01:00
gist_private.h Move fake LSN infrastructure out of GiST. 2026-03-13 19:38:17 -04:00
gistscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
gistxlog.h Move fake LSN infrastructure out of GiST. 2026-03-13 19:38:17 -04:00
hash.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
hash_xlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
heapam.h heapam: Track heap block in IndexFetchHeapData. 2026-04-04 11:45:33 -04:00
heapam_xlog.h Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
heaptoast.h Fix vicinity of tuple_insert to use uint32, not int, for options 2026-04-01 18:14:51 +02:00
hio.h Fix vicinity of tuple_insert to use uint32, not int, for options 2026-04-01 18:14:51 +02:00
htup.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
htup_details.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
itup.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
multixact.h Convert SLRUs to use the new shmem allocation functions 2026-04-06 02:13:02 +03:00
multixact_internal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nbtree.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
nbtxlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parallel.h Don't include proc.h in shm_mq.h 2026-02-27 10:53:47 +01:00
printsimple.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
printtup.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
relation.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
reloptions.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
relscan.h Add EXPLAIN (IO) infrastructure with BitmapHeapScan support 2026-04-07 22:33:34 +02:00
rewriteheap.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
rmgr.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
rmgrdesc_utils.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
rmgrlist.h Online enabling and disabling of data checksums 2026-04-03 22:58:51 +02:00
sdir.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sequence.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
session.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
skey.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
slru.h Convert SLRUs to use the new shmem allocation functions 2026-04-06 02:13:02 +03:00
spgist.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
spgist_private.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
spgxlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
stratnum.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
subtrans.h Convert SLRUs to use the new shmem allocation functions 2026-04-06 02:13:02 +03:00
syncscan.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
sysattr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
table.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tableam.h Add EXPLAIN (IO) infrastructure with BitmapHeapScan support 2026-04-07 22:33:34 +02:00
tidstore.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
timeline.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
toast_compression.h Change default value of default_toast_compression to "lz4", take two 2026-03-05 09:24:35 +09:00
toast_helper.h Fix vicinity of tuple_insert to use uint32, not int, for options 2026-04-01 18:14:51 +02:00
toast_internals.h Fix vicinity of tuple_insert to use uint32, not int, for options 2026-04-01 18:14:51 +02:00
transam.h Use the new shmem allocation functions in a few core subsystems 2026-04-06 02:12:59 +03:00
tsmapi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tupconvert.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tupdesc.h Bounds-check access to TupleDescAttr with an Assert. 2026-03-24 08:58:50 -04:00
tupdesc_details.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tupmacs.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
twophase.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
twophase_rmgr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
valid.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
visibilitymap.h Remove XLOG_HEAP2_VISIBLE entirely 2026-03-24 17:58:12 -04:00
visibilitymapdefs.h Remove XLOG_HEAP2_VISIBLE entirely 2026-03-24 17:58:12 -04:00
xact.h postgres_fdw: Inherit the local transaction's access/deferrable modes. 2026-04-05 18:55:00 +09:00
xlog.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
xlog_internal.h Allow logical replication snapshots to be database-specific 2026-04-07 12:31:18 +02:00
xlogarchive.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xlogbackup.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xlogdefs.h Rename AssertVariableIsOfType to StaticAssertVariableIsOfType 2026-02-03 08:45:24 +01:00
xloginsert.h Move fake LSN infrastructure out of GiST. 2026-03-13 19:38:17 -04:00
xlogprefetcher.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
xlogreader.h Report detailed errors from XLogFindNextRecord() failures. 2026-03-24 22:33:09 +09:00
xlogrecord.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xlogrecovery.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
xlogstats.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xlogutils.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xlogwait.h Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00