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

Commitb7e2cbc

Browse files
committed
Update Append's idea of first_partial_plan
It turns out that after runtime partition pruning, Append'sfirst_partial_plan does not accurately represent partial plans to run,if any of those got pruned. This could limit participation of workersin some partial subplans, if other subplans got pruned. Fix it bykeeping an index of the first valid partial subplan in the state node,determined at execnode Init time.Author: David Rowley, with cosmetic changes by me.Discussion:https://postgr.es/m/CAKJS1f8o2Yd=rOP=Et3A0FWgF+gSAOkFSU6eNhnGzTPV7nN8sQ@mail.gmail.com
1 parent5510154 commitb7e2cbc

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

‎src/backend/executor/nodeAppend.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
104104
PlanState**appendplanstates;
105105
Bitmapset*validsubplans;
106106
intnplans;
107+
intfirstvalid;
107108
inti,
108109
j;
109110
ListCell*lc;
@@ -207,19 +208,30 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
207208
/*
208209
* call ExecInitNode on each of the valid plans to be executed and save
209210
* the results into the appendplanstates array.
211+
*
212+
* While at it, find out the first valid partial plan.
210213
*/
211214
j=i=0;
215+
firstvalid=nplans;
212216
foreach(lc,node->appendplans)
213217
{
214218
if (bms_is_member(i,validsubplans))
215219
{
216220
Plan*initNode= (Plan*)lfirst(lc);
217221

222+
/*
223+
* Record the lowest appendplans index which is a valid partial
224+
* plan.
225+
*/
226+
if (i >=node->first_partial_plan&&j<firstvalid)
227+
firstvalid=j;
228+
218229
appendplanstates[j++]=ExecInitNode(initNode,estate,eflags);
219230
}
220231
i++;
221232
}
222233

234+
appendstate->as_first_partial_plan=firstvalid;
223235
appendstate->appendplans=appendplanstates;
224236
appendstate->as_nplans=nplans;
225237

@@ -499,7 +511,6 @@ static bool
499511
choose_next_subplan_for_leader(AppendState*node)
500512
{
501513
ParallelAppendState*pstate=node->as_pstate;
502-
Append*append= (Append*)node->ps.plan;
503514

504515
/* Backward scan is not supported by parallel-aware plans */
505516
Assert(ScanDirectionIsForward(node->ps.state->es_direction));
@@ -556,7 +567,7 @@ choose_next_subplan_for_leader(AppendState *node)
556567
}
557568

558569
/* If non-partial, immediately mark as finished. */
559-
if (node->as_whichplan<append->first_partial_plan)
570+
if (node->as_whichplan<node->as_first_partial_plan)
560571
node->as_pstate->pa_finished[node->as_whichplan]= true;
561572

562573
LWLockRelease(&pstate->pa_lock);
@@ -581,7 +592,6 @@ static bool
581592
choose_next_subplan_for_worker(AppendState*node)
582593
{
583594
ParallelAppendState*pstate=node->as_pstate;
584-
Append*append= (Append*)node->ps.plan;
585595

586596
/* Backward scan is not supported by parallel-aware plans */
587597
Assert(ScanDirectionIsForward(node->ps.state->es_direction));
@@ -629,14 +639,14 @@ choose_next_subplan_for_worker(AppendState *node)
629639
/* Advance to the next valid plan. */
630640
pstate->pa_next_plan=nextplan;
631641
}
632-
elseif (node->as_whichplan>append->first_partial_plan)
642+
elseif (node->as_whichplan>node->as_first_partial_plan)
633643
{
634644
/*
635645
* Try looping back to the first valid partial plan, if there is
636646
* one. If there isn't, arrange to bail out below.
637647
*/
638648
nextplan=bms_next_member(node->as_valid_subplans,
639-
append->first_partial_plan-1);
649+
node->as_first_partial_plan-1);
640650
pstate->pa_next_plan=
641651
nextplan<0 ?node->as_whichplan :nextplan;
642652
}
@@ -670,7 +680,7 @@ choose_next_subplan_for_worker(AppendState *node)
670680
if (pstate->pa_next_plan<0)
671681
{
672682
intnextplan=bms_next_member(node->as_valid_subplans,
673-
append->first_partial_plan-1);
683+
node->as_first_partial_plan-1);
674684

675685
if (nextplan >=0)
676686
pstate->pa_next_plan=nextplan;
@@ -686,7 +696,7 @@ choose_next_subplan_for_worker(AppendState *node)
686696
}
687697

688698
/* If non-partial, immediately mark as finished. */
689-
if (node->as_whichplan<append->first_partial_plan)
699+
if (node->as_whichplan<node->as_first_partial_plan)
690700
node->as_pstate->pa_finished[node->as_whichplan]= true;
691701

692702
LWLockRelease(&pstate->pa_lock);

‎src/include/nodes/execnodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,8 @@ struct AppendState
10871087
PlanState**appendplans;/* array of PlanStates for my inputs */
10881088
intas_nplans;
10891089
intas_whichplan;
1090+
intas_first_partial_plan;/* Index of 'appendplans' containing
1091+
* the first partial plan */
10901092
ParallelAppendState*as_pstate;/* parallel coordination info */
10911093
Sizepstate_len;/* size of parallel coordination info */
10921094
structPartitionPruneState*as_prune_state;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp