mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
BitmapHeapScan uses the read stream API
Make Bitmap Heap Scan use the read stream API instead of invoking ReadBuffer() for each block indicated by the bitmap. The read stream API handles prefetching, so remove all of the explicit prefetching from bitmap heap scan code. Now, heap table AM implements a read stream callback which uses the bitmap iterator to return the next required block to the read stream code. Tomas Vondra conducted extensive regression testing of this feature. Andres Freund, Thomas Munro, and I analyzed regressions and Thomas Munro patched the read stream API. Author: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Tested-by: Tomas Vondra <tomas@vondra.me> Tested-by: Andres Freund <andres@anarazel.de> Tested-by: Thomas Munro <thomas.munro@gmail.com> Tested-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/flat/CAAKRu_ZwCwWFeL_H3ia26bP2e7HiKLWt0ZmGXPVwPO6uXq0vaA%40mail.gmail.com
This commit is contained in:
@@ -797,28 +797,12 @@ typedef struct TableAmRoutine
|
||||
* always need to be rechecked, but some non-lossy pages' tuples may also
|
||||
* require recheck.
|
||||
*
|
||||
* `blockno` is the current block and is set by the table AM. The table AM
|
||||
* is responsible for advancing the main iterator, but the bitmap table
|
||||
* scan code still advances the prefetch iterator. `blockno` is used by
|
||||
* bitmap table scan code to validate that the prefetch block stays ahead
|
||||
* of the current block.
|
||||
*
|
||||
* XXX: Currently this may only be implemented if the AM uses md.c as its
|
||||
* storage manager, and uses ItemPointer->ip_blkid in a manner that maps
|
||||
* blockids directly to the underlying storage. nodeBitmapHeapscan.c
|
||||
* performs prefetching directly using that interface. This probably
|
||||
* needs to be rectified at a later point.
|
||||
*
|
||||
* XXX: Currently this may only be implemented if the AM uses the
|
||||
* visibilitymap, as nodeBitmapHeapscan.c unconditionally accesses it to
|
||||
* perform prefetching. This probably needs to be rectified at a later
|
||||
* point.
|
||||
* Prefetching additional data from the bitmap is left to the table AM.
|
||||
*
|
||||
* Optional callback, but either both scan_bitmap_next_block and
|
||||
* scan_bitmap_next_tuple need to exist, or neither.
|
||||
*/
|
||||
bool (*scan_bitmap_next_block) (TableScanDesc scan,
|
||||
BlockNumber *blockno,
|
||||
bool *recheck,
|
||||
uint64 *lossy_pages,
|
||||
uint64 *exact_pages);
|
||||
@@ -1966,16 +1950,11 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths,
|
||||
* `recheck` is set by the table AM to indicate whether or not the tuples
|
||||
* from this block should be rechecked.
|
||||
*
|
||||
* `blockno` is the current block and is set by the table AM and is used by
|
||||
* bitmap table scan code to validate that the prefetch block stays ahead of
|
||||
* the current block.
|
||||
*
|
||||
* Note, this is an optionally implemented function, therefore should only be
|
||||
* used after verifying the presence (at plan time or such).
|
||||
*/
|
||||
static inline bool
|
||||
table_scan_bitmap_next_block(TableScanDesc scan,
|
||||
BlockNumber *blockno,
|
||||
bool *recheck,
|
||||
uint64 *lossy_pages,
|
||||
uint64 *exact_pages)
|
||||
@@ -1989,7 +1968,7 @@ table_scan_bitmap_next_block(TableScanDesc scan,
|
||||
elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding");
|
||||
|
||||
return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
|
||||
blockno, recheck,
|
||||
recheck,
|
||||
lossy_pages,
|
||||
exact_pages);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user