Skip to content

Commit f35742c

Browse files
committed
Support parallel bitmap heap scans.
The index is scanned by a single process, but then all cooperating processes can iterate jointly over the resulting set of heap blocks. In the future, we might also want to support using a parallel bitmap index scan to set up for a parallel bitmap heap scan, but that's a job for another day. Dilip Kumar, with some corrections and cosmetic changes by me. The larger patch set of which this is a part has been reviewed and tested by (at least) Andres Freund, Amit Khandekar, Tushar Ahuja, Rafia Sabih, Haribabu Kommi, Thomas Munro, and me. Discussion: http://postgr.es/m/CAFiTN-uc4=0WxRGfCzs-xfkMYcSEWUC-Fon6thkJGjkh9i=13A@mail.gmail.com
1 parent 4eafdcc commit f35742c

File tree

24 files changed

+612
-55
lines changed

24 files changed

+612
-55
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
12111211
<entry>Waiting in an extension.</entry>
12121212
</row>
12131213
<row>
1214-
<entry morerows="10"><literal>IPC</></entry>
1214+
<entry morerows="11"><literal>IPC</></entry>
12151215
<entry><literal>BgWorkerShutdown</></entry>
12161216
<entry>Waiting for background worker to shut down.</entry>
12171217
</row>
@@ -1247,6 +1247,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
12471247
<entry><literal>ParallelFinish</></entry>
12481248
<entry>Waiting for parallel workers to finish computing.</entry>
12491249
</row>
1250+
<row>
1251+
<entry><literal>ParallelBitmapPopulate</></entry>
1252+
<entry>Waiting for the leader to populate the TidBitmap.</entry>
1253+
</row>
12501254
<row>
12511255
<entry><literal>SafeSnapshot</></entry>
12521256
<entry>Waiting for a snapshot for a <literal>READ ONLY DEFERRABLE</> transaction.</entry>

src/backend/access/heap/heapam.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,22 @@ heap_parallelscan_nextpage(HeapScanDesc scan)
17531753
return page;
17541754
}
17551755

1756+
/* ----------------
1757+
* heap_update_snapshot
1758+
*
1759+
* Update snapshot info in heap scan descriptor.
1760+
* ----------------
1761+
*/
1762+
void
1763+
heap_update_snapshot(HeapScanDesc scan, Snapshot snapshot)
1764+
{
1765+
Assert(IsMVCCSnapshot(snapshot));
1766+
1767+
RegisterSnapshot(snapshot);
1768+
scan->rs_snapshot = snapshot;
1769+
scan->rs_temp_snap = true;
1770+
}
1771+
17561772
/* ----------------
17571773
* heap_getnext - retrieve next tuple in scan
17581774
*

src/backend/executor/execParallel.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "executor/execParallel.h"
2727
#include "executor/executor.h"
28+
#include "executor/nodeBitmapHeapscan.h"
2829
#include "executor/nodeCustom.h"
2930
#include "executor/nodeForeignscan.h"
3031
#include "executor/nodeSeqscan.h"
@@ -217,6 +218,10 @@ ExecParallelEstimate(PlanState *planstate, ExecParallelEstimateContext *e)
217218
ExecCustomScanEstimate((CustomScanState *) planstate,
218219
e->pcxt);
219220
break;
221+
case T_BitmapHeapScanState:
222+
ExecBitmapHeapEstimate((BitmapHeapScanState *) planstate,
223+
e->pcxt);
224+
break;
220225
default:
221226
break;
222227
}
@@ -277,6 +282,11 @@ ExecParallelInitializeDSM(PlanState *planstate,
277282
ExecCustomScanInitializeDSM((CustomScanState *) planstate,
278283
d->pcxt);
279284
break;
285+
case T_BitmapHeapScanState:
286+
ExecBitmapHeapInitializeDSM((BitmapHeapScanState *) planstate,
287+
d->pcxt);
288+
break;
289+
280290
default:
281291
break;
282292
}
@@ -775,6 +785,10 @@ ExecParallelInitializeWorker(PlanState *planstate, shm_toc *toc)
775785
ExecCustomScanInitializeWorker((CustomScanState *) planstate,
776786
toc);
777787
break;
788+
case T_BitmapHeapScanState:
789+
ExecBitmapHeapInitializeWorker(
790+
(BitmapHeapScanState *) planstate, toc);
791+
break;
778792
default:
779793
break;
780794
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy