v21-0001-Reduce-code-duplication-in-set_append_rel_size.patch
text/plain
Filename: v21-0001-Reduce-code-duplication-in-set_append_rel_size.patch
Type: text/plain
Part: 0
Patch
Format: format-patch
Series: patch v21-0001
Subject: Reduce code-duplication in set_append_rel_size
| File | + | − |
|---|---|---|
| src/backend/optimizer/path/allpaths.c | 12 | 27 |
From 8f792a8492d5579c238cea8ba24bbebe6ace4d46 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Fri, 8 Feb 2019 15:06:25 +0900
Subject: [PATCH v21 1/6] Reduce code-duplication in set_append_rel_size
The code to mark a child rel dummy is repeated for 3 cases:
* child is pruned,
* contradictory quals found in apply_child_quals,
* child excluded due to constraints.
This combines the three cases in one if statement.
---
src/backend/optimizer/path/allpaths.c | 39 +++++++++++------------------------
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 55b871c02c..130efd6023 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -1015,6 +1015,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
RelOptInfo *childrel;
ListCell *parentvars;
ListCell *childvars;
+ bool childpruned;
/* append_rel_list contains all append rels; ignore others */
if (appinfo->parent_relid != parentRTindex)
@@ -1030,36 +1031,20 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
childrel = find_base_rel(root, childRTindex);
Assert(childrel->reloptkind == RELOPT_OTHER_MEMBER_REL);
- if (did_pruning && !bms_is_member(appinfo->child_relid, live_children))
- {
- /* This partition was pruned; skip it. */
- set_dummy_rel_pathlist(childrel);
- continue;
- }
-
+ childpruned = (did_pruning &&
+ !bms_is_member(appinfo->child_relid, live_children));
/*
- * We have to copy the parent's targetlist and quals to the child,
- * with appropriate substitution of variables. If any constant false
- * or NULL clauses turn up, we can disregard the child right away.
- * If not, we can apply constraint exclusion with just the
- * baserestrictinfo quals.
+ * Unless the child is pruned, we have to copy the parent's targetlist
+ * and quals to the child, with appropriate substitution of variables.
+ * If any constant false or NULL clauses turn up, we can disregard the
+ * child right away. If not, we can apply constraint exclusion with
+ * just the baserestrictinfo quals.
*/
- if (!apply_child_basequals(root, rel, childrel, childRTE, appinfo))
+ if (childpruned ||
+ !apply_child_basequals(root, rel, childrel, childRTE, appinfo) ||
+ relation_excluded_by_constraints(root, childrel, childRTE))
{
- /*
- * Some restriction clause reduced to constant FALSE or NULL after
- * substitution, so this child need not be scanned.
- */
- set_dummy_rel_pathlist(childrel);
- continue;
- }
-
- if (relation_excluded_by_constraints(root, childrel, childRTE))
- {
- /*
- * This child need not be scanned, so we can omit it from the
- * appendrel.
- */
+ /* This partition needn't be scanned; skip it. */
set_dummy_rel_pathlist(childrel);
continue;
}
--
2.11.0