diff options
author | Tom Lane | 2007-01-20 20:45:41 +0000 |
---|---|---|
committer | Tom Lane | 2007-01-20 20:45:41 +0000 |
commit | f41803bb39bc2949db200116a609fd242d0ec221 (patch) | |
tree | 2c81bcf712ab8b46133c2f50bbee34b2b3ea7129 /src/backend/optimizer/util/joininfo.c | |
parent | 2b7334d4877ba445003f96b0bb7eed4e7078a39b (diff) |
Refactor planner's pathkeys data structure to create a separate, explicit
representation of equivalence classes of variables. This is an extensive
rewrite, but it brings a number of benefits:
* planner no longer fails in the presence of "incomplete" operator families
that don't offer operators for every possible combination of datatypes.
* avoid generating and then discarding redundant equality clauses.
* remove bogus assumption that derived equalities always use operators
named "=".
* mergejoins can work with a variety of sort orders (e.g., descending) now,
instead of tying each mergejoinable operator to exactly one sort order.
* better recognition of redundant sort columns.
* can make use of equalities appearing underneath an outer join.
Diffstat (limited to 'src/backend/optimizer/util/joininfo.c')
-rw-r--r-- | src/backend/optimizer/util/joininfo.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/backend/optimizer/util/joininfo.c b/src/backend/optimizer/util/joininfo.c index 2971282bf3f..e58903c5d0a 100644 --- a/src/backend/optimizer/util/joininfo.c +++ b/src/backend/optimizer/util/joininfo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.46 2007/01/05 22:19:32 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.47 2007/01/20 20:45:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,7 @@ #include "optimizer/joininfo.h" #include "optimizer/pathnode.h" +#include "optimizer/paths.h" /* @@ -55,6 +56,13 @@ have_relevant_joinclause(PlannerInfo *root, } /* + * We also need to check the EquivalenceClass data structure, which + * might contain relationships not emitted into the joininfo lists. + */ + if (!result && rel1->has_eclass_joins && rel2->has_eclass_joins) + result = have_relevant_eclass_joinclause(root, rel1, rel2); + + /* * It's possible that the rels correspond to the left and right sides * of a degenerate outer join, that is, one with no joinclause mentioning * the non-nullable side. The above scan will then have failed to locate @@ -124,37 +132,3 @@ add_join_clause_to_rels(PlannerInfo *root, } bms_free(tmprelids); } - -/* - * remove_join_clause_from_rels - * Delete 'restrictinfo' from all the joininfo lists it is in - * - * This reverses the effect of add_join_clause_to_rels. It's used when we - * discover that a join clause is redundant. - * - * 'restrictinfo' describes the join clause - * 'join_relids' is the list of relations participating in the join clause - * (there must be more than one) - */ -void -remove_join_clause_from_rels(PlannerInfo *root, - RestrictInfo *restrictinfo, - Relids join_relids) -{ - Relids tmprelids; - int cur_relid; - - tmprelids = bms_copy(join_relids); - while ((cur_relid = bms_first_member(tmprelids)) >= 0) - { - RelOptInfo *rel = find_base_rel(root, cur_relid); - - /* - * Remove the restrictinfo from the list. Pointer comparison is - * sufficient. - */ - Assert(list_member_ptr(rel->joininfo, restrictinfo)); - rel->joininfo = list_delete_ptr(rel->joininfo, restrictinfo); - } - bms_free(tmprelids); -} |