aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/optimizer/path/allpaths.c18
-rw-r--r--src/backend/optimizer/path/joinrels.c16
-rw-r--r--src/backend/optimizer/util/relnode.c5
3 files changed, 8 insertions, 31 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 5bff90e1bca..6e842f93d0f 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -3425,20 +3425,8 @@ generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
if (!IS_JOIN_REL(rel))
return;
- /*
- * If we've already proven this join is empty, we needn't consider any
- * more paths for it.
- */
- if (IS_DUMMY_REL(rel))
- return;
-
- /*
- * We've nothing to do if the relation is not partitioned. An outer join
- * relation which had an empty inner relation in every pair will have the
- * rest of the partitioning properties set except the child-join
- * RelOptInfos. See try_partition_wise_join() for more details.
- */
- if (rel->nparts <= 0 || rel->part_rels == NULL)
+ /* We've nothing to do if the relation is not partitioned. */
+ if (!IS_PARTITIONED_REL(rel))
return;
/* Guard against stack overflow due to overly deep partition hierarchy. */
@@ -3452,6 +3440,8 @@ generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
{
RelOptInfo *child_rel = part_rels[cnt_parts];
+ Assert(child_rel != NULL);
+
/* Add partition-wise join paths for partitioned child-joins. */
generate_partition_wise_join_paths(root, child_rel);
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index a35d0689119..f74afdb4dda 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -1319,17 +1319,6 @@ try_partition_wise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
return;
/*
- * set_rel_pathlist() may not create paths in children of an empty
- * partitioned table and so we can not add paths to child-joins. So, deem
- * such a join as unpartitioned. When a partitioned relation is deemed
- * empty because all its children are empty, dummy path will be set in
- * each of the children. In such a case we could still consider the join
- * as partitioned, but it might not help much.
- */
- if (IS_DUMMY_REL(rel1) || IS_DUMMY_REL(rel2))
- return;
-
- /*
* Since this join relation is partitioned, all the base relations
* participating in this join must be partitioned and so are all the
* intermediate join relations.
@@ -1360,11 +1349,6 @@ try_partition_wise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
nparts = joinrel->nparts;
- /* Allocate space to hold child-joins RelOptInfos, if not already done. */
- if (!joinrel->part_rels)
- joinrel->part_rels =
- (RelOptInfo **) palloc0(sizeof(RelOptInfo *) * nparts);
-
/*
* Create child-join relations for this partitioned join, if those don't
* exist. Add paths to child-joins for a pair of child relations
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
index ac5a7c9553d..5c368321e6e 100644
--- a/src/backend/optimizer/util/relnode.c
+++ b/src/backend/optimizer/util/relnode.c
@@ -1662,11 +1662,14 @@ build_joinrel_partition_info(RelOptInfo *joinrel, RelOptInfo *outer_rel,
*/
joinrel->part_scheme = part_scheme;
joinrel->boundinfo = outer_rel->boundinfo;
- joinrel->nparts = outer_rel->nparts;
partnatts = joinrel->part_scheme->partnatts;
joinrel->partexprs = (List **) palloc0(sizeof(List *) * partnatts);
joinrel->nullable_partexprs =
(List **) palloc0(sizeof(List *) * partnatts);
+ joinrel->nparts = outer_rel->nparts;
+ joinrel->part_rels =
+ (RelOptInfo **) palloc0(sizeof(RelOptInfo *) * joinrel->nparts);
+
/*
* Construct partition keys for the join.