diff options
author | Andres Freund | 2025-04-02 18:25:17 +0000 |
---|---|---|
committer | Andres Freund | 2025-04-02 18:54:20 +0000 |
commit | 459e7bf8e2f8ab894dc613fa8555b74c4eef6969 (patch) | |
tree | d89ead863ddc22c0615d244c97ce26d3cf9cda32 /src/include | |
parent | 0dca5d68d7bebf2c1036fd84875533afef6df992 (diff) |
Remove HeapBitmapScan's skip_fetch optimization
The optimization does not take the removal of TIDs by a concurrent vacuum into
account. The concurrent vacuum can remove dead TIDs and make pages ALL_VISIBLE
while those dead TIDs are referenced in the bitmap. This can lead to a
skip_fetch scan returning too many tuples.
It likely would be possible to implement this optimization safely, but we
don't have the necessary infrastructure in place. Nor is it clear that it's
worth building that infrastructure, given how limited the skip_fetch
optimization is.
In the backbranches we just disable the optimization by always passing
need_tuples=true to table_beginscan_bm(). We can't perform API/ABI changes in
the backbranches and we want to make the change as minimal as possible.
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reported-By: Konstantin Knizhnik <knizhnik@garret.ru>
Discussion: https://postgr.es/m/CAEze2Wg3gXXZTr6_rwC+s4-o2ZVFB5F985uUSgJTsECx6AmGcQ@mail.gmail.com
Backpatch-through: 13
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/heapam.h | 12 | ||||
-rw-r--r-- | src/include/access/tableam.h | 12 |
2 files changed, 2 insertions, 22 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 1640d9c32f7..e48fe434cd3 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -103,17 +103,7 @@ typedef struct BitmapHeapScanDescData { HeapScanDescData rs_heap_base; - /* - * These fields are only used for bitmap scans for the "skip fetch" - * optimization. Bitmap scans needing no fields from the heap may skip - * fetching an all visible block, instead using the number of tuples per - * block reported by the bitmap to determine how many NULL-filled tuples - * to return. They are common to parallel and serial BitmapHeapScans - */ - - /* page of VM containing info for current block */ - Buffer rs_vmbuffer; - int rs_empty_tuples_pending; + /* Holds no data */ } BitmapHeapScanDescData; typedef struct BitmapHeapScanDescData *BitmapHeapScanDesc; diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index b8cb1e744ad..8713e12cbfb 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -62,13 +62,6 @@ typedef enum ScanOptions /* unregister snapshot at scan end? */ SO_TEMP_SNAPSHOT = 1 << 9, - - /* - * At the discretion of the table AM, bitmap table scans may be able to - * skip fetching a block from the table if none of the table data is - * needed. If table data may be needed, set SO_NEED_TUPLES. - */ - SO_NEED_TUPLES = 1 << 10, } ScanOptions; /* @@ -920,13 +913,10 @@ table_beginscan_strat(Relation rel, Snapshot snapshot, */ static inline TableScanDesc table_beginscan_bm(Relation rel, Snapshot snapshot, - int nkeys, struct ScanKeyData *key, bool need_tuple) + int nkeys, struct ScanKeyData *key) { uint32 flags = SO_TYPE_BITMAPSCAN | SO_ALLOW_PAGEMODE; - if (need_tuple) - flags |= SO_NEED_TUPLES; - return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags); } |