diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-08-15 12:30:38 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-08-15 12:30:38 -0400 |
commit | e139f1953f29db245f60a7acb72fccb1e05d2442 (patch) | |
tree | 783ae7f36a8066e9057d5ee275d5cc97870f8ee3 /src/backend/optimizer/path/joinpath.c | |
parent | 00418c61244138bd8ac2de58076a1d0dd4f539f3 (diff) | |
download | postgresql-e139f1953f29db245f60a7acb72fccb1e05d2442.tar.gz postgresql-e139f1953f29db245f60a7acb72fccb1e05d2442.zip |
Assorted preparatory refactoring for partition-wise join.
Instead of duplicating the logic to search for a matching
ParamPathInfo in multiple places, factor it out into a separate
function.
Pass only the relevant bits of the PartitionKey to
partition_bounds_equal instead of the whole thing, because
partition-wise join will want to call this without having a
PartitionKey available.
Adjust allow_star_schema_join and calc_nestloop_required_outer
to take relevant Relids rather than the entire Path, because
partition-wise join will want to call it with the top-parent
relids to determine whether a child join is allowable.
Ashutosh Bapat. Review and testing of the larger patch set of which
this is a part by Amit Langote, Rajkumar Raghuwanshi, Rafia Sabih,
Thomas Munro, Dilip Kumar, and me.
Discussion: http://postgr.es/m/CA+TgmobQK80vtXjAsPZWWXd7c8u13G86gmuLupN+uUJjA+i4nA@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/path/joinpath.c')
-rw-r--r-- | src/backend/optimizer/path/joinpath.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 511c7349805..43833ea9c9f 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -318,18 +318,15 @@ add_paths_to_joinrel(PlannerInfo *root, */ static inline bool allow_star_schema_join(PlannerInfo *root, - Path *outer_path, - Path *inner_path) + Relids outerrelids, + Relids inner_paramrels) { - Relids innerparams = PATH_REQ_OUTER(inner_path); - Relids outerrelids = outer_path->parent->relids; - /* * It's a star-schema case if the outer rel provides some but not all of * the inner rel's parameterization. */ - return (bms_overlap(innerparams, outerrelids) && - bms_nonempty_difference(innerparams, outerrelids)); + return (bms_overlap(inner_paramrels, outerrelids) && + bms_nonempty_difference(inner_paramrels, outerrelids)); } /* @@ -348,6 +345,12 @@ try_nestloop_path(PlannerInfo *root, { Relids required_outer; JoinCostWorkspace workspace; + RelOptInfo *innerrel = inner_path->parent; + RelOptInfo *outerrel = outer_path->parent; + Relids innerrelids = innerrel->relids; + Relids outerrelids = outerrel->relids; + Relids inner_paramrels = PATH_REQ_OUTER(inner_path); + Relids outer_paramrels = PATH_REQ_OUTER(outer_path); /* * Check to see if proposed path is still parameterized, and reject if the @@ -356,14 +359,12 @@ try_nestloop_path(PlannerInfo *root, * doesn't like the look of it, which could only happen if the nestloop is * still parameterized. */ - required_outer = calc_nestloop_required_outer(outer_path, - inner_path); + required_outer = calc_nestloop_required_outer(outerrelids, outer_paramrels, + innerrelids, inner_paramrels); if (required_outer && ((!bms_overlap(required_outer, extra->param_source_rels) && - !allow_star_schema_join(root, outer_path, inner_path)) || - have_dangerous_phv(root, - outer_path->parent->relids, - PATH_REQ_OUTER(inner_path)))) + !allow_star_schema_join(root, outerrelids, inner_paramrels)) || + have_dangerous_phv(root, outerrelids, inner_paramrels))) { /* Waste no memory when we reject a path here */ bms_free(required_outer); |