Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit05d0f13

Browse files
committed
Skip setting up shared instrumentation for Hash node if not needed.
We don't need to set up the shared space for hash join instrumentation dataif instrumentation hasn't been requested. Let's follow the example of thesimilar Sort node code and save a few cycles by skipping that when we can.This reverts commitd59ff4a and instead allows us to use the safer choiceof passing noError = false to shm_toc_lookup in ExecHashInitializeWorker,since if we reach that call there should be a TOC entry to be found.Thomas MunroDiscussion:https://postgr.es/m/E1ehkoZ-0005uW-43%40gemulon.postgresql.org
1 parentad14919 commit05d0f13

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

‎src/backend/executor/nodeHash.c‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,10 @@ ExecHashEstimate(HashState *node, ParallelContext *pcxt)
25492549
{
25502550
size_tsize;
25512551

2552+
/* don't need this if not instrumenting or no workers */
2553+
if (!node->ps.instrument||pcxt->nworkers==0)
2554+
return;
2555+
25522556
size=mul_size(pcxt->nworkers,sizeof(HashInstrumentation));
25532557
size=add_size(size, offsetof(SharedHashInfo,hinstrument));
25542558
shm_toc_estimate_chunk(&pcxt->estimator,size);
@@ -2564,6 +2568,10 @@ ExecHashInitializeDSM(HashState *node, ParallelContext *pcxt)
25642568
{
25652569
size_tsize;
25662570

2571+
/* don't need this if not instrumenting or no workers */
2572+
if (!node->ps.instrument||pcxt->nworkers==0)
2573+
return;
2574+
25672575
size= offsetof(SharedHashInfo,hinstrument)+
25682576
pcxt->nworkers*sizeof(HashInstrumentation);
25692577
node->shared_info= (SharedHashInfo*)shm_toc_allocate(pcxt->toc,size);
@@ -2582,13 +2590,13 @@ ExecHashInitializeWorker(HashState *node, ParallelWorkerContext *pwcxt)
25822590
{
25832591
SharedHashInfo*shared_info;
25842592

2585-
/* might not be there ... */
2593+
/* don't need this if not instrumenting */
2594+
if (!node->ps.instrument)
2595+
return;
2596+
25862597
shared_info= (SharedHashInfo*)
2587-
shm_toc_lookup(pwcxt->toc,node->ps.plan->plan_node_id, true);
2588-
if (shared_info)
2589-
node->hinstrument=&shared_info->hinstrument[ParallelWorkerNumber];
2590-
else
2591-
node->hinstrument=NULL;
2598+
shm_toc_lookup(pwcxt->toc,node->ps.plan->plan_node_id, false);
2599+
node->hinstrument=&shared_info->hinstrument[ParallelWorkerNumber];
25922600
}
25932601

25942602
/*
@@ -2614,6 +2622,9 @@ ExecHashRetrieveInstrumentation(HashState *node)
26142622
SharedHashInfo*shared_info=node->shared_info;
26152623
size_tsize;
26162624

2625+
if (shared_info==NULL)
2626+
return;
2627+
26172628
/* Replace node->shared_info with a copy in backend-local memory. */
26182629
size= offsetof(SharedHashInfo,hinstrument)+
26192630
shared_info->num_workers*sizeof(HashInstrumentation);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp