Skip to content

Commit 96030f9

Browse files
committed
Don't call IS_DUMMY_REL() when cheapest_total_path might be junk.
Unlike the previous coding, this might result in a Gather per Append subplan when the target list is parallel-restricted, but such a plan is probably worth considering in that case, since a single Gather on top of the entire Append is impossible. Per Andres Freund and the buildfarm. Discussion: http://postgr.es/m/20180330050351.bmxx4cdtz67czjda@alap3.anarazel.de
1 parent 681673e commit 96030f9

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,18 +1977,6 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
19771977
scanjoin_targets_contain_srfs = NIL;
19781978
}
19791979

1980-
/*
1981-
* If the final scan/join target is not parallel-safe, we must
1982-
* generate Gather paths now, since no partial paths will be generated
1983-
* with the final scan/join targetlist. Otherwise, the Gather or
1984-
* Gather Merge paths generated within apply_scanjoin_target_to_paths
1985-
* will be superior to any we might generate now in that the
1986-
* projection will be done in by each participant rather than only in
1987-
* the leader.
1988-
*/
1989-
if (!scanjoin_target_parallel_safe)
1990-
generate_gather_paths(root, current_rel, false);
1991-
19921980
/* Apply scan/join target. */
19931981
scanjoin_target_same_exprs = list_length(scanjoin_targets) == 1
19941982
&& equal(scanjoin_target->exprs, current_rel->reltarget->exprs);
@@ -6817,15 +6805,29 @@ apply_scanjoin_target_to_paths(PlannerInfo *root,
68176805
{
68186806
ListCell *lc;
68196807
PathTarget *scanjoin_target;
6808+
bool is_dummy_rel = IS_DUMMY_REL(rel);
68206809

68216810
check_stack_depth();
68226811

68236812
/*
6824-
* If the scan/join target is not parallel-safe, then the new partial
6825-
* pathlist is the empty list.
6813+
* If the scan/join target is not parallel-safe, partial paths cannot
6814+
* generate it.
68266815
*/
68276816
if (!scanjoin_target_parallel_safe)
68286817
{
6818+
/*
6819+
* Since we can't generate the final scan/join target, this is our
6820+
* last opportunity to use any partial paths that exist. We don't
6821+
* do this if the case where the target is parallel-safe, since we
6822+
* will be able to generate superior paths by doing it after the
6823+
* final scan/join target has been applied.
6824+
*
6825+
* Note that this may invalidate rel->cheapest_total_path, so we must
6826+
* not rely on it after this point without first calling set_cheapest.
6827+
*/
6828+
generate_gather_paths(root, rel, false);
6829+
6830+
/* Can't use parallel query above this level. */
68296831
rel->partial_pathlist = NIL;
68306832
rel->consider_parallel = false;
68316833
}
@@ -6840,7 +6842,7 @@ apply_scanjoin_target_to_paths(PlannerInfo *root,
68406842
rel->reltarget = llast_node(PathTarget, scanjoin_targets);
68416843

68426844
/* Special case: handly dummy relations separately. */
6843-
if (IS_DUMMY_REL(rel))
6845+
if (is_dummy_rel)
68446846
{
68456847
/*
68466848
* Since this is a dummy rel, it's got a single Append path with no

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy