aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/heapam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r--src/backend/access/heap/heapam.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index b12b583c4d9..6e433db039e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1206,7 +1206,15 @@ heap_beginscan(Relation relation, Snapshot snapshot,
else
cb = heap_scan_stream_read_next_serial;
- scan->rs_read_stream = read_stream_begin_relation(READ_STREAM_SEQUENTIAL,
+ /* ---
+ * It is safe to use batchmode as the only locks taken by `cb`
+ * are never taken while waiting for IO:
+ * - SyncScanLock is used in the non-parallel case
+ * - in the parallel case, only spinlocks and atomics are used
+ * ---
+ */
+ scan->rs_read_stream = read_stream_begin_relation(READ_STREAM_SEQUENTIAL |
+ READ_STREAM_USE_BATCHING,
scan->rs_strategy,
scan->rs_base.rs_rd,
MAIN_FORKNUM,
@@ -1216,6 +1224,12 @@ 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_strategy,
scan->rs_base.rs_rd,