aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeHash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r--src/backend/executor/nodeHash.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 70553b8fdf9..b10f8474527 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -2549,6 +2549,10 @@ ExecHashEstimate(HashState *node, ParallelContext *pcxt)
{
size_t size;
+ /* don't need this if not instrumenting or no workers */
+ if (!node->ps.instrument || pcxt->nworkers == 0)
+ return;
+
size = mul_size(pcxt->nworkers, sizeof(HashInstrumentation));
size = add_size(size, offsetof(SharedHashInfo, hinstrument));
shm_toc_estimate_chunk(&pcxt->estimator, size);
@@ -2564,6 +2568,10 @@ ExecHashInitializeDSM(HashState *node, ParallelContext *pcxt)
{
size_t size;
+ /* don't need this if not instrumenting or no workers */
+ if (!node->ps.instrument || pcxt->nworkers == 0)
+ return;
+
size = offsetof(SharedHashInfo, hinstrument) +
pcxt->nworkers * sizeof(HashInstrumentation);
node->shared_info = (SharedHashInfo *) shm_toc_allocate(pcxt->toc, size);
@@ -2582,13 +2590,13 @@ ExecHashInitializeWorker(HashState *node, ParallelWorkerContext *pwcxt)
{
SharedHashInfo *shared_info;
- /* might not be there ... */
+ /* don't need this if not instrumenting */
+ if (!node->ps.instrument)
+ return;
+
shared_info = (SharedHashInfo *)
- shm_toc_lookup(pwcxt->toc, node->ps.plan->plan_node_id, true);
- if (shared_info)
- node->hinstrument = &shared_info->hinstrument[ParallelWorkerNumber];
- else
- node->hinstrument = NULL;
+ shm_toc_lookup(pwcxt->toc, node->ps.plan->plan_node_id, false);
+ node->hinstrument = &shared_info->hinstrument[ParallelWorkerNumber];
}
/*
@@ -2614,6 +2622,9 @@ ExecHashRetrieveInstrumentation(HashState *node)
SharedHashInfo *shared_info = node->shared_info;
size_t size;
+ if (shared_info == NULL)
+ return;
+
/* Replace node->shared_info with a copy in backend-local memory. */
size = offsetof(SharedHashInfo, hinstrument) +
shared_info->num_workers * sizeof(HashInstrumentation);