aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/allpaths.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-06-09 12:40:23 -0400
committerRobert Haas <rhaas@postgresql.org>2016-06-09 12:43:36 -0400
commitb12fd41c695b43c76b0a9a4d19ba43b05536440c (patch)
tree966a7ca8b9c268b70f38257a56aeccaa25fd82b2 /src/backend/optimizer/path/allpaths.c
parente7bcd983f56136a9580076b60d5c19eb2fd83301 (diff)
downloadpostgresql-b12fd41c695b43c76b0a9a4d19ba43b05536440c.tar.gz
postgresql-b12fd41c695b43c76b0a9a4d19ba43b05536440c.zip
Don't generate parallel paths for rels with parallel-restricted outputs.
Such paths are unsafe. To make it cheaper to detect when this case applies, track whether a relation's default PathTarget contains any non-Vars. In most cases, the answer will be no, which enables us to determine cheaply that the target list for a proposed path is parallel-safe. However, subquery pull-up can create cases that require us to inspect the target list more carefully. Amit Kapila, reviewed by me.
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r--src/backend/optimizer/path/allpaths.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index cf6a9a9f82a..6deb2cf0c9c 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -608,6 +608,15 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel,
if (has_parallel_hazard((Node *) rel->baserestrictinfo, false))
return;
+ /*
+ * If the relation's outputs are not parallel-safe, we must give up.
+ * In the common case where the relation only outputs Vars, this check is
+ * very cheap; otherwise, we have to do more work.
+ */
+ if (rel->reltarget_has_non_vars &&
+ has_parallel_hazard((Node *) rel->reltarget->exprs, false))
+ return;
+
/* We have a winner. */
rel->consider_parallel = true;
}
@@ -971,6 +980,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
adjust_appendrel_attrs(root,
(Node *) rel->reltarget->exprs,
appinfo);
+ childrel->reltarget_has_non_vars = rel->reltarget_has_non_vars;
/*
* We have to make child entries in the EquivalenceClass data