Use AIO batchmode for bitmap heap scans
authorMelanie Plageman <[email protected]>
Thu, 3 Apr 2025 22:23:02 +0000 (18:23 -0400)
committerMelanie Plageman <[email protected]>
Thu, 3 Apr 2025 22:23:02 +0000 (18:23 -0400)
Previously bitmap heap scan was not AIO batchmode safe because of the
visibility map reads potentially done for the "skip fetch" optimization
(which skipped fetching tuples from the heap if the pages were all
visible and none of the columns were used in the query).

The skip fetch optimization implementation was found to have bugs and
was removed in 459e7bf8e2f8, so we can safely enable batchmode for
bitmap heap scans.

src/backend/access/heap/heapam.c

index 5b3fe4a1d3bd1b26ca2e9b7c3ce50e6db2201b05..ed2e302179929b23fa9b8211341b922d9183efaf 100644 (file)
@@ -1204,13 +1204,8 @@ heap_beginscan(Relation relation, Snapshot snapshot,
    }
    else if (scan->rs_base.rs_flags & SO_TYPE_BITMAPSCAN)
    {
-       /*
-        * Currently we can't trivially use batching, due to the
-        * VM_ALL_VISIBLE check in bitmapheap_stream_read_next. While that
-        * could be made safe, we are about to remove the all-visible logic
-        * from bitmap scans due to its unsoundness.
-        */
-       scan->rs_read_stream = read_stream_begin_relation(READ_STREAM_DEFAULT,
+       scan->rs_read_stream = read_stream_begin_relation(READ_STREAM_DEFAULT |
+                                                         READ_STREAM_USE_BATCHING,
                                                          scan->rs_strategy,
                                                          scan->rs_base.rs_rd,
                                                          MAIN_FORKNUM,