|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "executor/execParallel.h"#include "executor/executor.h"#include "executor/nodeAgg.h"#include "executor/nodeAppend.h"#include "executor/nodeBitmapHeapscan.h"#include "executor/nodeBitmapIndexscan.h"#include "executor/nodeCustom.h"#include "executor/nodeForeignscan.h"#include "executor/nodeHash.h"#include "executor/nodeHashjoin.h"#include "executor/nodeIncrementalSort.h"#include "executor/nodeIndexonlyscan.h"#include "executor/nodeIndexscan.h"#include "executor/nodeMemoize.h"#include "executor/nodeSeqscan.h"#include "executor/nodeSort.h"#include "executor/nodeSubplan.h"#include "executor/nodeTidrangescan.h"#include "executor/tqueue.h"#include "jit/jit.h"#include "nodes/nodeFuncs.h"#include "pgstat.h"#include "storage/proc.h"#include "tcop/tcopprot.h"#include "utils/datum.h"#include "utils/dsa.h"#include "utils/lsyscache.h"#include "utils/snapmgr.h"
Go to the source code of this file.
Data Structures | |
| struct | FixedParallelExecutorState |
| struct | SharedExecutorInstrumentation |
| struct | ExecParallelEstimateContext |
| struct | ExecParallelInitializeDSMContext |
Macros | |
| #define | PARALLEL_KEY_EXECUTOR_FIXED UINT64CONST(0xE000000000000001) |
| #define | PARALLEL_KEY_PLANNEDSTMT UINT64CONST(0xE000000000000002) |
| #define | PARALLEL_KEY_PARAMLISTINFO UINT64CONST(0xE000000000000003) |
| #define | PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xE000000000000004) |
| #define | PARALLEL_KEY_TUPLE_QUEUE UINT64CONST(0xE000000000000005) |
| #define | PARALLEL_KEY_INSTRUMENTATION UINT64CONST(0xE000000000000006) |
| #define | PARALLEL_KEY_DSA UINT64CONST(0xE000000000000007) |
| #define | PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xE000000000000008) |
| #define | PARALLEL_KEY_JIT_INSTRUMENTATION UINT64CONST(0xE000000000000009) |
| #define | PARALLEL_KEY_WAL_USAGE UINT64CONST(0xE00000000000000A) |
| #define | PARALLEL_TUPLE_QUEUE_SIZE 65536 |
| #define | GetInstrumentationArray(sei) |
Definition at line 113 of file execParallel.c.
| #define PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xE000000000000004) |
Definition at line 63 of file execParallel.c.
| #define PARALLEL_KEY_DSA UINT64CONST(0xE000000000000007) |
Definition at line 66 of file execParallel.c.
| #define PARALLEL_KEY_EXECUTOR_FIXED UINT64CONST(0xE000000000000001) |
Definition at line 60 of file execParallel.c.
| #define PARALLEL_KEY_INSTRUMENTATION UINT64CONST(0xE000000000000006) |
Definition at line 65 of file execParallel.c.
| #define PARALLEL_KEY_JIT_INSTRUMENTATION UINT64CONST(0xE000000000000009) |
Definition at line 68 of file execParallel.c.
| #define PARALLEL_KEY_PARAMLISTINFO UINT64CONST(0xE000000000000003) |
Definition at line 62 of file execParallel.c.
| #define PARALLEL_KEY_PLANNEDSTMT UINT64CONST(0xE000000000000002) |
Definition at line 61 of file execParallel.c.
| #define PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xE000000000000008) |
Definition at line 67 of file execParallel.c.
| #define PARALLEL_KEY_TUPLE_QUEUE UINT64CONST(0xE000000000000005) |
Definition at line 64 of file execParallel.c.
| #define PARALLEL_KEY_WAL_USAGE UINT64CONST(0xE00000000000000A) |
Definition at line 69 of file execParallel.c.
| #define PARALLEL_TUPLE_QUEUE_SIZE 65536 |
Definition at line 71 of file execParallel.c.
Definition at line 352 of file execParallel.c.
References add_size(), bms_next_member(), datumEstimateSpace(), EState::es_param_exec_vals, EState::es_plannedstmt, fb(), get_typlenbyval(), list_nth_oid(), OidIsValid, and PlannedStmt::paramExecTypes.
Referenced by SerializeParamExecParams().
| ParallelExecutorInfo * ExecInitParallelPlan | ( | PlanState * | planstate, |
| EState * | estate, | ||
| Bitmapset * | sendParams, | ||
| int | nworkers, | ||
| int64 | tuples_needed | ||
| ) |
Definition at line 653 of file execParallel.c.
References ParallelExecutorInfo::area, Assert, bms_is_empty, ParallelExecutorInfo::buffer_usage, CreateParallelContext(), dsa_create_in_place, dsa_minimum_size(), elog, ERROR, EState::es_instrument, EState::es_jit_flags, EState::es_param_list_info, EState::es_query_dsa, EState::es_snapshot, EState::es_sourceText, EState::es_top_eflags, EstimateParamListSpace(), ParallelContext::estimator, ExecParallelEstimate(), ExecParallelInitializeDSM(), ExecParallelSetupTupleQueues(), ExecSerializePlan(), ExecSetParamPlanMulti(), fb(), ParallelExecutorInfo::finished, GetActiveSnapshot(), GetInstrumentationArray, GetPerTupleExprContext, i, InitializeParallelDSM(), InstrInitNode(), SharedExecutorInstrumentation::instrument_offset, SharedExecutorInstrumentation::instrument_options, ExecParallelInitializeDSMContext::instrumentation, ParallelExecutorInfo::instrumentation, InvalidDsaPointer, SharedJitInstrumentation::jit_instr, ParallelExecutorInfo::jit_instrumentation, MAXALIGN, memcpy(), mul_size(), ExecParallelInitializeDSMContext::nnodes, SharedExecutorInstrumentation::num_plan_nodes, SharedExecutorInstrumentation::num_workers, SharedJitInstrumentation::num_workers, ParallelContext::nworkers, palloc0_object, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_DSA, PARALLEL_KEY_EXECUTOR_FIXED, PARALLEL_KEY_INSTRUMENTATION, PARALLEL_KEY_JIT_INSTRUMENTATION, PARALLEL_KEY_PARAMLISTINFO, PARALLEL_KEY_PLANNEDSTMT, PARALLEL_KEY_QUERY_TEXT, PARALLEL_KEY_WAL_USAGE, PARALLEL_TUPLE_QUEUE_SIZE, ParallelExecutorInfo::param_exec, ExecParallelInitializeDSMContext::pcxt, ParallelExecutorInfo::pcxt, PGJIT_NONE, PlanState::plan, ParallelExecutorInfo::planstate, ParallelExecutorInfo::reader, ParallelContext::seg, SerializeParamExecParams(), SerializeParamList(), shm_toc_allocate(), shm_toc_estimate_chunk, shm_toc_estimate_keys, shm_toc_insert(), ParallelContext::toc, ParallelExecutorInfo::tqueue, and ParallelExecutorInfo::wal_usage.
Referenced by ExecGather(), and ExecGatherMerge().
| void ExecParallelCleanup | ( | ParallelExecutorInfo * | pei | ) |
Definition at line 1274 of file execParallel.c.
References ParallelExecutorInfo::area, DestroyParallelContext(), dsa_detach(), dsa_free(), DsaPointerIsValid, ExecParallelRetrieveInstrumentation(), ExecParallelRetrieveJitInstrumentation(), fb(), ParallelExecutorInfo::instrumentation, InvalidDsaPointer, ParallelExecutorInfo::jit_instrumentation, ParallelExecutorInfo::param_exec, ParallelExecutorInfo::pcxt, pfree(), and ParallelExecutorInfo::planstate.
Referenced by ExecShutdownGather(), and ExecShutdownGatherMerge().
| void ExecParallelCreateReaders | ( | ParallelExecutorInfo * | pei | ) |
Definition at line 944 of file execParallel.c.
References Assert, ParallelWorkerInfo::bgwhandle, CreateTupleQueueReader(), fb(), i, ParallelContext::nworkers_launched, palloc(), ParallelExecutorInfo::pcxt, ParallelExecutorInfo::reader, shm_mq_set_handle(), ParallelExecutorInfo::tqueue, and ParallelContext::worker.
Referenced by ExecGather(), and ExecGatherMerge().
|
static |
Definition at line 246 of file execParallel.c.
References ExecAggEstimate(), ExecAppendEstimate(), ExecBitmapHeapEstimate(), ExecBitmapHeapInstrumentEstimate(), ExecBitmapIndexScanEstimate(), ExecCustomScanEstimate(), ExecForeignScanEstimate(), ExecHashEstimate(), ExecHashJoinEstimate(), ExecIncrementalSortEstimate(), ExecIndexOnlyScanEstimate(), ExecIndexOnlyScanInstrumentEstimate(), ExecIndexScanEstimate(), ExecIndexScanInstrumentEstimate(), ExecMemoizeEstimate(), ExecParallelEstimate(), ExecSeqScanEstimate(), ExecSeqScanInstrumentEstimate(), ExecSortEstimate(), ExecTidRangeScanEstimate(), ExecTidRangeScanInstrumentEstimate(), fb(), nodeTag, Plan::parallel_aware, PlanState::plan, and planstate_tree_walker.
Referenced by ExecInitParallelPlan(), and ExecParallelEstimate().
| void ExecParallelFinish | ( | ParallelExecutorInfo * | pei | ) |
Definition at line 1221 of file execParallel.c.
References ParallelExecutorInfo::buffer_usage, DestroyTupleQueueReader(), fb(), ParallelExecutorInfo::finished, i, InstrAccumParallelQuery(), ParallelContext::nworkers_launched, ParallelExecutorInfo::pcxt, pfree(), ParallelExecutorInfo::reader, shm_mq_detach(), ParallelExecutorInfo::tqueue, WaitForParallelWorkersToFinish(), and ParallelExecutorInfo::wal_usage.
Referenced by ExecShutdownGatherMergeWorkers(), and ExecShutdownGatherWorkers().
|
static |
Definition at line 1326 of file execParallel.c.
References CreateQueryDesc(), fb(), GetActiveSnapshot(), InvalidSnapshot, PARALLEL_KEY_PARAMLISTINFO, PARALLEL_KEY_PLANNEDSTMT, PARALLEL_KEY_QUERY_TEXT, RestoreParamList(), shm_toc_lookup(), and stringToNode().
Referenced by ParallelQueryMain().
|
static |
Definition at line 1310 of file execParallel.c.
References CreateTupleQueueDestReceiver(), fb(), MyProc, PARALLEL_KEY_TUPLE_QUEUE, PARALLEL_TUPLE_QUEUE_SIZE, ParallelWorkerNumber, shm_mq_attach(), shm_mq_set_sender(), and shm_toc_lookup().
Referenced by ParallelQueryMain().
|
static |
Definition at line 480 of file execParallel.c.
References ExecAggInitializeDSM(), ExecAppendInitializeDSM(), ExecBitmapHeapInitializeDSM(), ExecBitmapHeapInstrumentInitDSM(), ExecBitmapIndexScanInitializeDSM(), ExecCustomScanInitializeDSM(), ExecForeignScanInitializeDSM(), ExecHashInitializeDSM(), ExecHashJoinInitializeDSM(), ExecIncrementalSortInitializeDSM(), ExecIndexOnlyScanInitializeDSM(), ExecIndexOnlyScanInstrumentInitDSM(), ExecIndexScanInitializeDSM(), ExecIndexScanInstrumentInitDSM(), ExecMemoizeInitializeDSM(), ExecParallelInitializeDSM(), ExecSeqScanInitializeDSM(), ExecSeqScanInstrumentInitDSM(), ExecSortInitializeDSM(), ExecTidRangeScanInitializeDSM(), ExecTidRangeScanInstrumentInitDSM(), fb(), ExecParallelInitializeDSMContext::instrumentation, ExecParallelInitializeDSMContext::nnodes, nodeTag, Plan::parallel_aware, ExecParallelInitializeDSMContext::pcxt, PlanState::plan, SharedExecutorInstrumentation::plan_node_id, Plan::plan_node_id, and planstate_tree_walker.
Referenced by ExecInitParallelPlan(), and ExecParallelInitializeDSM().
|
static |
Definition at line 1399 of file execParallel.c.
References ExecAggInitializeWorker(), ExecAppendInitializeWorker(), ExecBitmapHeapInitializeWorker(), ExecBitmapHeapInstrumentInitWorker(), ExecBitmapIndexScanInitializeWorker(), ExecCustomScanInitializeWorker(), ExecForeignScanInitializeWorker(), ExecHashInitializeWorker(), ExecHashJoinInitializeWorker(), ExecIncrementalSortInitializeWorker(), ExecIndexOnlyScanInitializeWorker(), ExecIndexOnlyScanInstrumentInitWorker(), ExecIndexScanInitializeWorker(), ExecIndexScanInstrumentInitWorker(), ExecMemoizeInitializeWorker(), ExecParallelInitializeWorker(), ExecSeqScanInitializeWorker(), ExecSeqScanInstrumentInitWorker(), ExecSortInitializeWorker(), ExecTidRangeScanInitializeWorker(), ExecTidRangeScanInstrumentInitWorker(), fb(), nodeTag, Plan::parallel_aware, PlanState::plan, and planstate_tree_walker.
Referenced by ExecParallelInitializeWorker(), and ParallelQueryMain().
| void ExecParallelReinitialize | ( | PlanState * | planstate, |
| ParallelExecutorInfo * | pei, | ||
| Bitmapset * | sendParams | ||
| ) |
Definition at line 970 of file execParallel.c.
References ParallelExecutorInfo::area, Assert, bms_is_empty, dsa_free(), DsaPointerIsValid, EState::es_query_dsa, ExecParallelReInitializeDSM(), ExecParallelSetupTupleQueues(), ExecSetParamPlanMulti(), fb(), ParallelExecutorInfo::finished, GetPerTupleExprContext, InvalidDsaPointer, PARALLEL_KEY_EXECUTOR_FIXED, ParallelExecutorInfo::param_exec, ParallelExecutorInfo::pcxt, ParallelExecutorInfo::reader, ReinitializeParallelDSM(), SerializeParamExecParams(), shm_toc_lookup(), PlanState::state, ParallelContext::toc, and ParallelExecutorInfo::tqueue.
Referenced by ExecGather(), and ExecGatherMerge().
|
static |
Definition at line 1019 of file execParallel.c.
References ExecAppendReInitializeDSM(), ExecBitmapHeapReInitializeDSM(), ExecCustomScanReInitializeDSM(), ExecForeignScanReInitializeDSM(), ExecHashJoinReInitializeDSM(), ExecIndexOnlyScanReInitializeDSM(), ExecIndexScanReInitializeDSM(), ExecParallelReInitializeDSM(), ExecSeqScanReInitializeDSM(), ExecTidRangeScanReInitializeDSM(), fb(), nodeTag, Plan::parallel_aware, PlanState::plan, and planstate_tree_walker.
Referenced by ExecParallelReinitialize(), and ExecParallelReInitializeDSM().
|
static |
Definition at line 1358 of file execParallel.c.
References Assert, elog, ERROR, ExecParallelReportInstrumentation(), fb(), GetInstrumentationArray, i, InstrAggNode(), InstrEndLoop(), PlanState::instrument, IsParallelWorker, SharedExecutorInstrumentation::num_plan_nodes, SharedExecutorInstrumentation::num_workers, ParallelWorkerNumber, PlanState::plan, SharedExecutorInstrumentation::plan_node_id, Plan::plan_node_id, and planstate_tree_walker.
Referenced by ExecParallelReportInstrumentation(), and ParallelQueryMain().
|
static |
Definition at line 1094 of file execParallel.c.
References elog, ERROR, EState::es_query_cxt, ExecAggRetrieveInstrumentation(), ExecBitmapHeapRetrieveInstrumentation(), ExecBitmapIndexScanRetrieveInstrumentation(), ExecHashRetrieveInstrumentation(), ExecIncrementalSortRetrieveInstrumentation(), ExecIndexOnlyScanRetrieveInstrumentation(), ExecIndexScanRetrieveInstrumentation(), ExecMemoizeRetrieveInstrumentation(), ExecParallelRetrieveInstrumentation(), ExecSeqScanRetrieveInstrumentation(), ExecSortRetrieveInstrumentation(), ExecTidRangeScanRetrieveInstrumentation(), fb(), GetInstrumentationArray, i, InstrAggNode(), WorkerNodeInstrumentation::instrument, PlanState::instrument, memcpy(), MemoryContextSwitchTo(), mul_size(), nodeTag, SharedExecutorInstrumentation::num_plan_nodes, SharedExecutorInstrumentation::num_workers, WorkerNodeInstrumentation::num_workers, palloc(), PlanState::plan, SharedExecutorInstrumentation::plan_node_id, Plan::plan_node_id, planstate_tree_walker, PlanState::state, and PlanState::worker_instrument.
Referenced by ExecParallelCleanup(), and ExecParallelRetrieveInstrumentation().
|
static |
Definition at line 1181 of file execParallel.c.
References EState::es_jit_worker_instr, EState::es_query_cxt, fb(), InstrJitAgg(), memcpy(), MemoryContextAlloc(), MemoryContextAllocZero(), mul_size(), PlanState::state, and PlanState::worker_jit_instrument.
Referenced by ExecParallelCleanup().
|
static |
Definition at line 601 of file execParallel.c.
References fb(), i, mul_size(), MyProc, ParallelContext::nworkers, palloc(), PARALLEL_KEY_TUPLE_QUEUE, PARALLEL_TUPLE_QUEUE_SIZE, ParallelContext::seg, shm_mq_attach(), shm_mq_create(), shm_mq_set_receiver(), shm_toc_allocate(), shm_toc_insert(), shm_toc_lookup(), and ParallelContext::toc.
Referenced by ExecInitParallelPlan(), and ExecParallelReinitialize().
Definition at line 152 of file execParallel.c.
References PlannedStmt::appendRelations, PlannedStmt::canSetTag, CMD_SELECT, PlannedStmt::commandType, copyObject, PlannedStmt::dependsOnRole, EState::es_part_prune_infos, EState::es_plannedstmt, EState::es_range_table, EState::es_rteperminfos, EState::es_unpruned_relids, fb(), PlannedStmt::hasModifyingCTE, PlannedStmt::hasReturning, PlannedStmt::invalItems, lappend(), lfirst, lfirst_node, makeNode, NIL, nodeToString(), Plan::parallel_safe, PlannedStmt::parallelModeNeeded, PlannedStmt::paramExecTypes, PlannedStmt::partPruneInfos, PlannedStmt::permInfos, pgstat_get_my_plan_id(), pgstat_get_my_query_id(), plan, PLAN_STMT_INTERNAL, PlannedStmt::planId, PlannedStmt::planOrigin, PlannedStmt::planTree, PlannedStmt::queryId, PlannedStmt::relationOids, PlannedStmt::resultRelationRelids, PlannedStmt::rewindPlanIDs, PlannedStmt::rowMarkRelids, PlannedStmt::rowMarks, PlannedStmt::rtable, PlannedStmt::stmt_len, PlannedStmt::stmt_location, PlannedStmt::subplans, PlannedStmt::transientPlan, PlannedStmt::unprunableRelids, and PlannedStmt::utilityStmt.
Referenced by ExecInitParallelPlan().
| void ParallelQueryMain | ( | dsm_segment * | seg, |
| shm_toc * | toc | ||
| ) |
Definition at line 1514 of file execParallel.c.
References Assert, debug_query_string, dsa_attach_in_place(), dsa_detach(), dsa_get_address(), DsaPointerIsValid, EState::es_jit, EState::es_query_dsa, QueryDesc::estate, ExecParallelGetQueryDesc(), ExecParallelGetReceiver(), ExecParallelInitializeWorker(), ExecParallelReportInstrumentation(), ExecSetTupleBound(), ExecutorEnd(), ExecutorFinish(), ExecutorRun(), ExecutorStart(), fb(), ForwardScanDirection, FreeQueryDesc(), JitContext::instr, InstrEndParallelQuery(), InstrStartParallelQuery(), SharedExecutorInstrumentation::instrument_options, SharedJitInstrumentation::jit_instr, PlannedStmt::jitFlags, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_DSA, PARALLEL_KEY_EXECUTOR_FIXED, PARALLEL_KEY_INSTRUMENTATION, PARALLEL_KEY_JIT_INSTRUMENTATION, PARALLEL_KEY_WAL_USAGE, ParallelWorkerNumber, pgstat_report_activity(), QueryDesc::plannedstmt, QueryDesc::planstate, RestoreParamExecParams(), shm_toc_lookup(), QueryDesc::sourceText, PlanState::state, and STATE_RUNNING.
Definition at line 451 of file execParallel.c.
References datumRestore(), EState::es_param_exec_vals, fb(), i, and memcpy().
Referenced by ParallelQueryMain().
|
static |
Definition at line 396 of file execParallel.c.
References bms_next_member(), bms_num_members(), datumSerialize(), dsa_allocate, dsa_get_address(), EState::es_param_exec_vals, EState::es_plannedstmt, EstimateParamExecSpace(), fb(), get_typlenbyval(), list_nth_oid(), memcpy(), OidIsValid, and PlannedStmt::paramExecTypes.
Referenced by ExecInitParallelPlan(), and ExecParallelReinitialize().