Expand description
Bitmap heap scan — Fase 5 P6 consumer of TidBitmap.
Implements the second half of the PG bitmap-index-scan
pipeline: given a TidBitmap produced by AND/OR-ing
per-index bitmaps, walk the target heap pages in sorted
order and fetch the rows corresponding to set bits.
The win over a plain index scan is sequential page access: bitmap entries are sorted by TID, so successive fetches go to adjacent pages, giving the OS and buffer pool a prefetch-friendly stream instead of random seeks. For queries touching >1% of a large table the difference is 5-20× on spinning disks and ~2-3× on SSDs.
Mirrors PG’s nodeBitmapHeapscan.c modulo features we
don’t have:
- Lossy bitmap entries: PG’s tidbitmap can spill to
page-level granularity when memory pressure mounts.
TidBitmapdoesn’t, so the bitmap heap scan here always processes tuple-level entries. - Prefetch hints: PG calls
PrefetchBufferfor the next few pages while the current page is being processed. We rely on the OS readahead for now. - Parallel bitmap heap scans: single-producer for now.
This module is not yet wired into the canonical plan.
A BitmapHeapScan logical plan node and its executor
arm plug into query_exec/table.rs when the planner
learns to emit bitmap paths.
Structs§
- Bitmap
Scan Stats - Summary statistics the bitmap scan returns alongside its
output. Useful for
EXPLAIN ANALYZE-style diagnostics and for the planner’s feedback loop when adjusting cost estimates based on actual selectivity.
Enums§
- Bitmap
Combine - Boolean combinator passed into
execute_combined_bitmap_scan.
Traits§
- RowFetcher
- Callback the bitmap scan uses to fetch a row by its TID. The caller (typically the runtime executor) provides this when invoking the scan because the row shape depends on the target collection.
Functions§
- execute_
bitmap_ scan - Execute a bitmap heap scan over
bitmap, invokingfetcherfor each surviving TID in sorted order. Returns the materialised rows in the same TID order. - execute_
bitmap_ scan_ with_ stats - Variant of
execute_bitmap_scanthat also fills aBitmapScanStatsstruct alongside the row output. Used byEXPLAIN ANALYZEpaths and by the runtime’s cardinality feedback loop. - execute_
combined_ bitmap_ scan - Phase 3.6 wiring entry point. Combines a list of per-index bitmaps via the requested boolean op and runs a single heap fetch over the result. The planner uses this when WHERE has multi-index AND/OR predicates.