mirror of
https://github.com/postgres/postgres.git
synced 2025-11-26 23:43:30 +03:00
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
/*
|
||||
@@ -54,6 +55,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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user