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/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/tqueue.h"
#include "jit/jit.h"
#include "nodes/nodeFuncs.h"
#include "pgstat.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) |
Typedefs | |
typedef struct FixedParallelExecutorState | FixedParallelExecutorState |
typedef struct ExecParallelEstimateContext | ExecParallelEstimateContext |
typedef struct ExecParallelInitializeDSMContext | ExecParallelInitializeDSMContext |
#define GetInstrumentationArray | ( | sei | ) |
Definition at line 106 of file execParallel.c.
#define PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xE000000000000004) |
Definition at line 60 of file execParallel.c.
#define PARALLEL_KEY_DSA UINT64CONST(0xE000000000000007) |
Definition at line 63 of file execParallel.c.
#define PARALLEL_KEY_EXECUTOR_FIXED UINT64CONST(0xE000000000000001) |
Definition at line 57 of file execParallel.c.
#define PARALLEL_KEY_INSTRUMENTATION UINT64CONST(0xE000000000000006) |
Definition at line 62 of file execParallel.c.
#define PARALLEL_KEY_JIT_INSTRUMENTATION UINT64CONST(0xE000000000000009) |
Definition at line 65 of file execParallel.c.
#define PARALLEL_KEY_PARAMLISTINFO UINT64CONST(0xE000000000000003) |
Definition at line 59 of file execParallel.c.
#define PARALLEL_KEY_PLANNEDSTMT UINT64CONST(0xE000000000000002) |
Definition at line 58 of file execParallel.c.
#define PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xE000000000000008) |
Definition at line 64 of file execParallel.c.
#define PARALLEL_KEY_TUPLE_QUEUE UINT64CONST(0xE000000000000005) |
Definition at line 61 of file execParallel.c.
#define PARALLEL_KEY_WAL_USAGE UINT64CONST(0xE00000000000000A) |
Definition at line 66 of file execParallel.c.
#define PARALLEL_TUPLE_QUEUE_SIZE 65536 |
Definition at line 68 of file execParallel.c.
typedef struct ExecParallelEstimateContext ExecParallelEstimateContext |
typedef struct ExecParallelInitializeDSMContext ExecParallelInitializeDSMContext |
typedef struct FixedParallelExecutorState FixedParallelExecutorState |
Definition at line 310 of file execParallel.c.
References add_size(), bms_next_member(), datumEstimateSpace(), EState::es_param_exec_vals, EState::es_plannedstmt, get_typlenbyval(), ParamExecData::isnull, list_nth_oid(), OidIsValid, PlannedStmt::paramExecTypes, and ParamExecData::value.
Referenced by SerializeParamExecParams().
ParallelExecutorInfo * ExecInitParallelPlan | ( | PlanState * | planstate, |
EState * | estate, | ||
Bitmapset * | sendParams, | ||
int | nworkers, | ||
int64 | tuples_needed | ||
) |
Definition at line 587 of file execParallel.c.
References ParallelExecutorInfo::area, Assert, bms_is_empty, ParallelExecutorInfo::buffer_usage, CreateParallelContext(), dsa_create_in_place, dsa_minimum_size(), FixedParallelExecutorState::eflags, 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(), ParallelExecutorInfo::finished, GetActiveSnapshot(), GetInstrumentationArray, GetPerTupleExprContext, i, InitializeParallelDSM(), InstrInit(), SharedExecutorInstrumentation::instrument_offset, SharedExecutorInstrumentation::instrument_options, ExecParallelInitializeDSMContext::instrumentation, ParallelExecutorInfo::instrumentation, InvalidDsaPointer, FixedParallelExecutorState::jit_flags, SharedJitInstrumentation::jit_instr, ParallelExecutorInfo::jit_instrumentation, LWTRANCHE_PARALLEL_QUERY_DSA, MAXALIGN, mul_size(), ExecParallelInitializeDSMContext::nnodes, SharedExecutorInstrumentation::num_plan_nodes, SharedExecutorInstrumentation::num_workers, SharedJitInstrumentation::num_workers, ParallelContext::nworkers, palloc0(), 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, FixedParallelExecutorState::param_exec, 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, FixedParallelExecutorState::tuples_needed, and ParallelExecutorInfo::wal_usage.
Referenced by ExecGather(), and ExecGatherMerge().
void ExecParallelCleanup | ( | ParallelExecutorInfo * | pei | ) |
Definition at line 1187 of file execParallel.c.
References ParallelExecutorInfo::area, DestroyParallelContext(), dsa_detach(), dsa_free(), DsaPointerIsValid, ExecParallelRetrieveInstrumentation(), ExecParallelRetrieveJitInstrumentation(), 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 878 of file execParallel.c.
References Assert, ParallelWorkerInfo::bgwhandle, CreateTupleQueueReader(), 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 229 of file execParallel.c.
References ExecAggEstimate(), ExecAppendEstimate(), ExecBitmapHeapEstimate(), ExecCustomScanEstimate(), ExecForeignScanEstimate(), ExecHashEstimate(), ExecHashJoinEstimate(), ExecIncrementalSortEstimate(), ExecIndexOnlyScanEstimate(), ExecIndexScanEstimate(), ExecMemoizeEstimate(), ExecParallelEstimate(), ExecSeqScanEstimate(), ExecSortEstimate(), nodeTag, Plan::parallel_aware, PlanState::plan, and planstate_tree_walker.
Referenced by ExecInitParallelPlan(), and ExecParallelEstimate().
void ExecParallelFinish | ( | ParallelExecutorInfo * | pei | ) |
Definition at line 1134 of file execParallel.c.
References ParallelExecutorInfo::buffer_usage, DestroyTupleQueueReader(), 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 1239 of file execParallel.c.
References CreateQueryDesc(), 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 1223 of file execParallel.c.
References CreateTupleQueueDestReceiver(), 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 438 of file execParallel.c.
References ExecAggInitializeDSM(), ExecAppendInitializeDSM(), ExecBitmapHeapInitializeDSM(), ExecCustomScanInitializeDSM(), ExecForeignScanInitializeDSM(), ExecHashInitializeDSM(), ExecHashJoinInitializeDSM(), ExecIncrementalSortInitializeDSM(), ExecIndexOnlyScanInitializeDSM(), ExecIndexScanInitializeDSM(), ExecMemoizeInitializeDSM(), ExecParallelInitializeDSM(), ExecSeqScanInitializeDSM(), ExecSortInitializeDSM(), 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 1312 of file execParallel.c.
References ExecAggInitializeWorker(), ExecAppendInitializeWorker(), ExecBitmapHeapInitializeWorker(), ExecCustomScanInitializeWorker(), ExecForeignScanInitializeWorker(), ExecHashInitializeWorker(), ExecHashJoinInitializeWorker(), ExecIncrementalSortInitializeWorker(), ExecIndexOnlyScanInitializeWorker(), ExecIndexScanInitializeWorker(), ExecMemoizeInitializeWorker(), ExecParallelInitializeWorker(), ExecSeqScanInitializeWorker(), ExecSortInitializeWorker(), 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 904 of file execParallel.c.
References ParallelExecutorInfo::area, Assert, bms_is_empty, dsa_free(), DsaPointerIsValid, EState::es_query_dsa, ExecParallelReInitializeDSM(), ExecParallelSetupTupleQueues(), ExecSetParamPlanMulti(), ParallelExecutorInfo::finished, GetPerTupleExprContext, InvalidDsaPointer, PARALLEL_KEY_EXECUTOR_FIXED, FixedParallelExecutorState::param_exec, 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 953 of file execParallel.c.
References ExecAppendReInitializeDSM(), ExecBitmapHeapReInitializeDSM(), ExecCustomScanReInitializeDSM(), ExecForeignScanReInitializeDSM(), ExecHashJoinReInitializeDSM(), ExecIndexOnlyScanReInitializeDSM(), ExecIndexScanReInitializeDSM(), ExecParallelReInitializeDSM(), ExecSeqScanReInitializeDSM(), nodeTag, Plan::parallel_aware, PlanState::plan, and planstate_tree_walker.
Referenced by ExecParallelReinitialize(), and ExecParallelReInitializeDSM().
|
static |
Definition at line 1271 of file execParallel.c.
References Assert, elog, ERROR, ExecParallelReportInstrumentation(), 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 1022 of file execParallel.c.
References elog, ERROR, EState::es_query_cxt, ExecAggRetrieveInstrumentation(), ExecBitmapHeapRetrieveInstrumentation(), ExecHashRetrieveInstrumentation(), ExecIncrementalSortRetrieveInstrumentation(), ExecMemoizeRetrieveInstrumentation(), ExecParallelRetrieveInstrumentation(), ExecSortRetrieveInstrumentation(), GetInstrumentationArray, i, InstrAggNode(), WorkerInstrumentation::instrument, PlanState::instrument, MemoryContextSwitchTo(), mul_size(), nodeTag, SharedExecutorInstrumentation::num_plan_nodes, SharedExecutorInstrumentation::num_workers, WorkerInstrumentation::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 1094 of file execParallel.c.
References EState::es_jit_worker_instr, EState::es_query_cxt, InstrJitAgg(), SharedJitInstrumentation::jit_instr, MemoryContextAlloc(), MemoryContextAllocZero(), mul_size(), SharedJitInstrumentation::num_workers, PlanState::state, and PlanState::worker_jit_instrument.
Referenced by ExecParallelCleanup().
|
static |
Definition at line 535 of file execParallel.c.
References 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 145 of file execParallel.c.
References PlannedStmt::appendRelations, PlannedStmt::canSetTag, CMD_SELECT, PlannedStmt::commandType, copyObject, PlannedStmt::dependsOnRole, EState::es_plannedstmt, EState::es_range_table, EState::es_rteperminfos, PlannedStmt::hasModifyingCTE, PlannedStmt::hasReturning, PlannedStmt::invalItems, lappend(), lfirst, lfirst_node, makeNode, NIL, nodeToString(), Plan::parallel_safe, PlannedStmt::parallelModeNeeded, PlannedStmt::paramExecTypes, PlannedStmt::permInfos, pgstat_get_my_query_id(), plan, PlannedStmt::planTree, PlannedStmt::queryId, PlannedStmt::relationOids, PlannedStmt::resultRelations, PlannedStmt::rewindPlanIDs, PlannedStmt::rowMarks, PlannedStmt::rtable, PlannedStmt::stmt_len, PlannedStmt::stmt_location, PlannedStmt::subplans, PlannedStmt::transientPlan, and PlannedStmt::utilityStmt.
Referenced by ExecInitParallelPlan().
void ParallelQueryMain | ( | dsm_segment * | seg, |
shm_toc * | toc | ||
) |
Definition at line 1403 of file execParallel.c.
References Assert, debug_query_string, dsa_attach_in_place(), dsa_detach(), dsa_get_address(), DsaPointerIsValid, FixedParallelExecutorState::eflags, EState::es_jit, EState::es_query_dsa, QueryDesc::estate, ExecParallelGetQueryDesc(), ExecParallelGetReceiver(), ExecParallelInitializeWorker(), ExecParallelReportInstrumentation(), ExecSetTupleBound(), ExecutorEnd(), ExecutorFinish(), ExecutorRun(), ExecutorStart(), ForwardScanDirection, FreeQueryDesc(), JitContext::instr, InstrEndParallelQuery(), InstrStartParallelQuery(), SharedExecutorInstrumentation::instrument_options, FixedParallelExecutorState::jit_flags, 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, FixedParallelExecutorState::param_exec, pgstat_report_activity(), QueryDesc::plannedstmt, QueryDesc::planstate, _DestReceiver::rDestroy, RestoreParamExecParams(), ParallelWorkerContext::seg, shm_toc_lookup(), QueryDesc::sourceText, PlanState::state, STATE_RUNNING, ParallelWorkerContext::toc, and FixedParallelExecutorState::tuples_needed.
|
static |
Definition at line 409 of file execParallel.c.
References datumRestore(), EState::es_param_exec_vals, ParamExecData::execPlan, i, ParamExecData::isnull, and ParamExecData::value.
Referenced by ParallelQueryMain().
|
static |
Definition at line 354 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(), get_typlenbyval(), ParamExecData::isnull, list_nth_oid(), OidIsValid, PlannedStmt::paramExecTypes, size, and ParamExecData::value.
Referenced by ExecInitParallelPlan(), and ExecParallelReinitialize().