PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nodeBitmapHeapscan.h File Reference
#include "access/parallel.h"
#include "nodes/execnodes.h"
Include dependency graph for nodeBitmapHeapscan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BitmapHeapScanStateExecInitBitmapHeapScan (BitmapHeapScan *node, EState *estate, int eflags)
 
void ExecEndBitmapHeapScan (BitmapHeapScanState *node)
 
void ExecReScanBitmapHeapScan (BitmapHeapScanState *node)
 
void ExecBitmapHeapEstimate (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInitializeDSM (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapReInitializeDSM (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInitializeWorker (BitmapHeapScanState *node, ParallelWorkerContext *pwcxt)
 
void ExecBitmapHeapInstrumentEstimate (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInstrumentInitDSM (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInstrumentInitWorker (BitmapHeapScanState *node, ParallelWorkerContext *pwcxt)
 
void ExecBitmapHeapRetrieveInstrumentation (BitmapHeapScanState *node)
 

Function Documentation

◆ ExecBitmapHeapEstimate()

void ExecBitmapHeapEstimate ( BitmapHeapScanState node,
ParallelContext pcxt 
)
extern

Definition at line 510 of file nodeBitmapHeapscan.c.

512{
516}
#define MAXALIGN(LEN)
Definition c.h:896
#define shm_toc_estimate_chunk(e, sz)
Definition shm_toc.h:51
#define shm_toc_estimate_keys(e, cnt)
Definition shm_toc.h:53
shm_toc_estimator estimator
Definition parallel.h:43

References ParallelContext::estimator, MAXALIGN, shm_toc_estimate_chunk, and shm_toc_estimate_keys.

Referenced by ExecParallelEstimate().

◆ ExecBitmapHeapInitializeDSM()

void ExecBitmapHeapInitializeDSM ( BitmapHeapScanState node,
ParallelContext pcxt 
)
extern

Definition at line 525 of file nodeBitmapHeapscan.c.

527{
529 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
530
531 /* If there's no DSA, there are no workers; initialize nothing. */
532 if (dsa == NULL)
533 return;
534
535 pstate = (ParallelBitmapHeapState *)
536 shm_toc_allocate(pcxt->toc,
538
539 pstate->tbmiterator = 0;
540
541 /* Initialize the mutex */
542 SpinLockInit(&pstate->mutex);
543 pstate->state = BM_INITIAL;
544
545 ConditionVariableInit(&pstate->cv);
546
547 shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, pstate);
548 node->pstate = pstate;
549}
void ConditionVariableInit(ConditionVariable *cv)
@ BM_INITIAL
static int fb(int x)
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition shm_toc.c:88
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition shm_toc.c:171
static void SpinLockInit(volatile slock_t *lock)
Definition spin.h:50
ParallelBitmapHeapState * pstate
Definition execnodes.h:1882
struct dsa_area * es_query_dsa
Definition execnodes.h:788
shm_toc * toc
Definition parallel.h:46
Plan * plan
Definition execnodes.h:1201
EState * state
Definition execnodes.h:1203
int plan_node_id
Definition plannodes.h:233
PlanState ps
Definition execnodes.h:1659

References BM_INITIAL, ConditionVariableInit(), ParallelBitmapHeapState::cv, EState::es_query_dsa, fb(), MAXALIGN, ParallelBitmapHeapState::mutex, PlanState::plan, Plan::plan_node_id, ScanState::ps, BitmapHeapScanState::pstate, shm_toc_allocate(), shm_toc_insert(), SpinLockInit(), BitmapHeapScanState::ss, ParallelBitmapHeapState::state, PlanState::state, ParallelBitmapHeapState::tbmiterator, and ParallelContext::toc.

Referenced by ExecParallelInitializeDSM().

◆ ExecBitmapHeapInitializeWorker()

void ExecBitmapHeapInitializeWorker ( BitmapHeapScanState node,
ParallelWorkerContext pwcxt 
)
extern

Definition at line 583 of file nodeBitmapHeapscan.c.

585{
586 Assert(node->ss.ps.state->es_query_dsa != NULL);
587
589 shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
590}
#define Assert(condition)
Definition c.h:943
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition shm_toc.c:239

References Assert, EState::es_query_dsa, fb(), PlanState::plan, Plan::plan_node_id, ScanState::ps, BitmapHeapScanState::pstate, shm_toc_lookup(), BitmapHeapScanState::ss, and PlanState::state.

Referenced by ExecParallelInitializeWorker().

◆ ExecBitmapHeapInstrumentEstimate()

void ExecBitmapHeapInstrumentEstimate ( BitmapHeapScanState node,
ParallelContext pcxt 
)
extern

Definition at line 597 of file nodeBitmapHeapscan.c.

599{
600 Size size;
601
602 if (!node->ss.ps.instrument || pcxt->nworkers == 0)
603 return;
604
607 shm_toc_estimate_chunk(&pcxt->estimator, size);
609}
size_t Size
Definition c.h:689
Size add_size(Size s1, Size s2)
Definition shmem.c:1048
Size mul_size(Size s1, Size s2)
Definition shmem.c:1063
NodeInstrumentation * instrument
Definition execnodes.h:1211

References add_size(), ParallelContext::estimator, fb(), PlanState::instrument, mul_size(), ParallelContext::nworkers, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, and BitmapHeapScanState::ss.

Referenced by ExecParallelEstimate().

◆ ExecBitmapHeapInstrumentInitDSM()

void ExecBitmapHeapInstrumentInitDSM ( BitmapHeapScanState node,
ParallelContext pcxt 
)
extern

◆ ExecBitmapHeapInstrumentInitWorker()

◆ ExecBitmapHeapReInitializeDSM()

void ExecBitmapHeapReInitializeDSM ( BitmapHeapScanState node,
ParallelContext pcxt 
)
extern

Definition at line 558 of file nodeBitmapHeapscan.c.

560{
561 ParallelBitmapHeapState *pstate = node->pstate;
562 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
563
564 /* If there's no DSA, there are no workers; do nothing. */
565 if (dsa == NULL)
566 return;
567
568 pstate->state = BM_INITIAL;
569
570 if (DsaPointerIsValid(pstate->tbmiterator))
571 tbm_free_shared_area(dsa, pstate->tbmiterator);
572
574}
#define InvalidDsaPointer
Definition dsa.h:78
#define DsaPointerIsValid(x)
Definition dsa.h:106
void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
Definition tidbitmap.c:331

References BM_INITIAL, DsaPointerIsValid, EState::es_query_dsa, fb(), InvalidDsaPointer, ScanState::ps, BitmapHeapScanState::pstate, BitmapHeapScanState::ss, ParallelBitmapHeapState::state, PlanState::state, tbm_free_shared_area(), and ParallelBitmapHeapState::tbmiterator.

Referenced by ExecParallelReInitializeDSM().

◆ ExecBitmapHeapRetrieveInstrumentation()

void ExecBitmapHeapRetrieveInstrumentation ( BitmapHeapScanState node)
extern

Definition at line 661 of file nodeBitmapHeapscan.c.

662{
663 SharedBitmapHeapInstrumentation *sinstrument = node->sinstrument;
664 Size size;
665
666 if (sinstrument == NULL)
667 return;
668
669 size = offsetof(SharedBitmapHeapInstrumentation, sinstrument)
670 + sinstrument->num_workers * sizeof(BitmapHeapScanInstrumentation);
671
672 node->sinstrument = palloc(size);
673 memcpy(node->sinstrument, sinstrument, size);
674}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void * palloc(Size size)
Definition mcxt.c:1387

References fb(), memcpy(), SharedBitmapHeapInstrumentation::num_workers, palloc(), and BitmapHeapScanState::sinstrument.

Referenced by ExecParallelRetrieveInstrumentation().

◆ ExecEndBitmapHeapScan()

void ExecEndBitmapHeapScan ( BitmapHeapScanState node)
extern

Definition at line 315 of file nodeBitmapHeapscan.c.

316{
318
319 /*
320 * When ending a parallel worker, copy the statistics gathered by the
321 * worker back into shared memory so that it can be picked up by the main
322 * process to report in EXPLAIN ANALYZE.
323 */
324 if (node->sinstrument != NULL && IsParallelWorker())
325 {
327
328 Assert(ParallelWorkerNumber < node->sinstrument->num_workers);
330
331 /*
332 * Here we accumulate the stats rather than performing memcpy on
333 * node->stats into si. When a Gather/GatherMerge node finishes it
334 * will perform planner shutdown on the workers. On rescan it will
335 * spin up new workers which will have a new BitmapHeapScanState and
336 * zeroed stats.
337 */
339 si->lossy_pages += node->stats.lossy_pages;
340
341 /* collect I/O instrumentation for this process */
342 if (node->ss.ss_currentScanDesc &&
344 {
345 AccumulateIOStats(&si->stats.io,
347 }
348 }
349
350 /*
351 * extract information from the node
352 */
354
355 /*
356 * close down subplans
357 */
359
360 if (scanDesc)
361 {
362 /*
363 * End iteration on iterators saved in scan descriptor if they have
364 * not already been cleaned up.
365 */
366 if (!tbm_exhausted(&scanDesc->st.rs_tbmiterator))
367 tbm_end_iterate(&scanDesc->st.rs_tbmiterator);
368
369 /*
370 * close table scan
371 */
373 }
374
375 /*
376 * release bitmaps and buffers if any
377 */
378 if (node->tbm)
379 tbm_free(node->tbm);
380}
int ParallelWorkerNumber
Definition parallel.c:117
void ExecEndNode(PlanState *node)
#define outerPlanState(node)
Definition execnodes.h:1299
#define IsParallelWorker()
Definition parallel.h:62
static void AccumulateIOStats(IOStats *dst, IOStats *src)
BitmapHeapScanInstrumentation stats
Definition execnodes.h:1880
struct TableScanDescData * ss_currentScanDesc
Definition execnodes.h:1661
BitmapHeapScanInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
struct TableScanInstrumentation * rs_instrument
Definition relscan.h:72
static void table_endscan(TableScanDesc scan)
Definition tableam.h:1061
void tbm_free(TIDBitmap *tbm)
Definition tidbitmap.c:312
void tbm_end_iterate(TBMIterator *iterator)
Definition tidbitmap.c:1594
static bool tbm_exhausted(TBMIterator *iterator)
Definition tidbitmap.h:118

References AccumulateIOStats(), Assert, BitmapHeapScanInstrumentation::exact_pages, ExecEndNode(), fb(), TableScanInstrumentation::io, IsParallelWorker, BitmapHeapScanInstrumentation::lossy_pages, outerPlanState, ParallelWorkerNumber, TableScanDescData::rs_instrument, SharedBitmapHeapInstrumentation::sinstrument, BitmapHeapScanState::sinstrument, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, BitmapHeapScanState::stats, table_endscan(), BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_exhausted(), and tbm_free().

Referenced by ExecEndNode().

◆ ExecInitBitmapHeapScan()

BitmapHeapScanState * ExecInitBitmapHeapScan ( BitmapHeapScan node,
EState estate,
int  eflags 
)
extern

Definition at line 389 of file nodeBitmapHeapscan.c.

390{
393
394 /* check for unsupported flags */
396
397 /*
398 * Assert caller didn't ask for an unsafe snapshot --- see comments at
399 * head of file.
400 */
402
403 /*
404 * create state structure
405 */
407 scanstate->ss.ps.plan = (Plan *) node;
408 scanstate->ss.ps.state = estate;
409 scanstate->ss.ps.ExecProcNode = ExecBitmapHeapScan;
410
411 scanstate->tbm = NULL;
412
413 /* Zero the statistics counters */
415
416 scanstate->initialized = false;
417 scanstate->pstate = NULL;
418 scanstate->recheck = true;
419
420 /*
421 * Miscellaneous initialization
422 *
423 * create expression context for node
424 */
425 ExecAssignExprContext(estate, &scanstate->ss.ps);
426
427 /*
428 * open the scan relation
429 */
430 currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
431
432 /*
433 * initialize child nodes
434 */
435 outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
436
437 /*
438 * get the scan type from the relation descriptor.
439 */
440 ExecInitScanTupleSlot(estate, &scanstate->ss,
444
445 /*
446 * Initialize result type and projection.
447 */
450
451 /*
452 * initialize child expressions
453 */
454 scanstate->ss.ps.qual =
455 ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
456 scanstate->bitmapqualorig =
458
459 scanstate->ss.ss_currentRelation = currentRelation;
460
461 /*
462 * all done.
463 */
464 return scanstate;
465}
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition execExpr.c:250
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
void ExecAssignScanProjectionInfo(ScanState *node)
Definition execScan.c:81
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops, uint16 flags)
void ExecInitResultTypeTL(PlanState *planstate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:490
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition execUtils.c:768
#define EXEC_FLAG_BACKWARD
Definition executor.h:70
#define EXEC_FLAG_MARK
Definition executor.h:71
static TupleTableSlot * ExecBitmapHeapScan(PlanState *pstate)
#define makeNode(_type_)
Definition nodes.h:161
#define outerPlan(node)
Definition plannodes.h:267
#define RelationGetDescr(relation)
Definition rel.h:542
#define IsMVCCSnapshot(snapshot)
Definition snapmgr.h:59
List * bitmapqualorig
Definition plannodes.h:714
Snapshot es_snapshot
Definition execnodes.h:696
Index scanrelid
Definition plannodes.h:544
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition tableam.c:59
#define TTS_FLAG_OBEYS_NOT_NULL_CONSTRAINTS
Definition tuptable.h:102

References Assert, BitmapHeapScan::bitmapqualorig, EState::es_snapshot, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecBitmapHeapScan(), ExecInitNode(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), fb(), IsMVCCSnapshot, makeNode, outerPlan, outerPlanState, RelationGetDescr, BitmapHeapScan::scan, Scan::scanrelid, table_slot_callbacks(), and TTS_FLAG_OBEYS_NOT_NULL_CONSTRAINTS.

Referenced by ExecInitNode().

◆ ExecReScanBitmapHeapScan()

void ExecReScanBitmapHeapScan ( BitmapHeapScanState node)
extern

Definition at line 274 of file nodeBitmapHeapscan.c.

275{
277
279
280 if (scan)
281 {
282 /*
283 * End iteration on iterators saved in scan descriptor if they have
284 * not already been cleaned up.
285 */
286 if (!tbm_exhausted(&scan->st.rs_tbmiterator))
288
289 /* rescan to release any page pin */
291 }
292
293 /* release bitmaps and buffers if any */
294 if (node->tbm)
295 tbm_free(node->tbm);
296 node->tbm = NULL;
297 node->initialized = false;
298 node->recheck = true;
299
300 ExecScanReScan(&node->ss);
301
302 /*
303 * if chgParam of subnode is not null then plan will be re-scanned by
304 * first ExecProcNode.
305 */
306 if (outerPlan->chgParam == NULL)
308}
void ExecReScan(PlanState *node)
Definition execAmi.c:78
void ExecScanReScan(ScanState *node)
Definition execScan.c:108
TBMIterator rs_tbmiterator
Definition relscan.h:47
union TableScanDescData::@55 st
static void table_rescan(TableScanDesc scan, ScanKeyData *key)
Definition tableam.h:1070

References ExecReScan(), ExecScanReScan(), fb(), BitmapHeapScanState::initialized, outerPlan, outerPlanState, BitmapHeapScanState::recheck, TableScanDescData::rs_tbmiterator, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, TableScanDescData::st, table_rescan(), BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_exhausted(), and tbm_free().

Referenced by ExecReScan().