PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "catalog/pg_class.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/joininfo.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "optimizer/restrictinfo.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Data Structures | |
struct | SelfJoinCandidate |
struct | ReplaceVarnoContext |
Variables | |
bool | enable_self_join_removal |
|
inlinestatic |
Definition at line 145 of file analyzejoins.c.
References bms_is_subset().
Referenced by is_innerrel_unique_for(), and join_is_removable().
Definition at line 1184 of file analyzejoins.c.
References forboth, InvalidOid, lfirst_int, and lfirst_oid.
Referenced by query_is_distinct_for().
bool innerrel_is_unique | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
Relids | outerrelids, | ||
RelOptInfo * | innerrel, | ||
JoinType | jointype, | ||
List * | restrictlist, | ||
bool | force_cache | ||
) |
Definition at line 1224 of file analyzejoins.c.
References innerrel_is_unique_ext(), and root.
Referenced by add_paths_to_joinrel(), and reduce_unique_semijoins().
bool innerrel_is_unique_ext | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
Relids | outerrelids, | ||
RelOptInfo * | innerrel, | ||
JoinType | jointype, | ||
List * | restrictlist, | ||
bool | force_cache, | ||
List ** | extra_clauses | ||
) |
Definition at line 1244 of file analyzejoins.c.
References bms_copy(), bms_equal(), bms_is_subset(), UniqueRelInfo::extra_clauses, is_innerrel_unique_for(), lappend(), lfirst, makeNode, MemoryContextSwitchTo(), NIL, RelOptInfo::non_unique_for_rels, UniqueRelInfo::outerrelids, rel_supports_distinctness(), root, UniqueRelInfo::self_join, and RelOptInfo::unique_for_rels.
Referenced by innerrel_is_unique(), and remove_self_joins_one_group().
|
static |
Definition at line 1374 of file analyzejoins.c.
References clause_sides_match_join(), IS_OUTER_JOIN, lappend(), lfirst, NIL, rel_is_distinct_for(), RelOptInfo::relids, RINFO_IS_PUSHED_DOWN, and root.
Referenced by innerrel_is_unique_ext().
|
static |
Definition at line 177 of file analyzejoins.c.
References Assert, bms_add_member(), bms_copy(), bms_get_singleton_member(), bms_is_member(), bms_is_subset(), bms_overlap(), bms_union(), clause_sides_match_join(), find_base_rel(), RestrictInfo::is_clone, JOIN_LEFT, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lappend(), lfirst, RelOptInfo::max_attr, RelOptInfo::min_attr, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, NIL, SpecialJoinInfo::ojrelid, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_lateral, PlaceHolderInfo::ph_needed, PlaceHolderInfo::ph_var, pull_varnos(), rel_is_distinct_for(), rel_supports_distinctness(), RelOptInfo::relids, RINFO_IS_PUSHED_DOWN, and root.
Referenced by remove_useless_joins().
|
static |
Definition at line 2041 of file analyzejoins.c.
References Assert, RelOptInfo::baserestrictinfo, bms_is_empty, RestrictInfo::clause, copyObject, equal(), get_leftop(), get_rightop(), is_opclause(), lfirst_node, NIL, RelOptInfo::relid, and replace_varno().
Referenced by remove_self_joins_one_group().
Definition at line 1035 of file analyzejoins.c.
References SetOperationStmt::all, Assert, castNode, distinct_col_search(), Query::distinctClause, SortGroupClause::eqop, equality_ops_are_compatible(), get_sortgroupclause_tle(), Query::groupClause, GROUPING_SET_EMPTY, Query::groupingSets, Query::havingQual, lfirst, linitial, list_head(), list_length(), lnext(), OidIsValid, SetOperationStmt::op, TargetEntry::resno, SETOP_NONE, Query::setOperations, and Query::targetList.
Referenced by create_unique_path(), and rel_is_distinct_for().
Definition at line 998 of file analyzejoins.c.
References Query::distinctClause, Query::groupClause, Query::groupingSets, Query::havingQual, NIL, and Query::setOperations.
Referenced by create_unique_path(), and rel_supports_distinctness().
void reduce_unique_semijoins | ( | PlannerInfo * | root | ) |
Definition at line 764 of file analyzejoins.c.
References Assert, bms_get_singleton_member(), bms_union(), find_base_rel(), foreach_delete_current, generate_join_implied_equalities(), innerrel_is_unique(), JOIN_SEMI, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lfirst, list_concat(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, rel_supports_distinctness(), and root.
Referenced by query_planner().
|
static |
Definition at line 899 of file analyzejoins.c.
References castNode, RestrictInfo::clause, get_leftop(), get_rightop(), IsA, lappend_int(), lappend_oid(), lfirst_node, NIL, query_is_distinct_for(), relation_has_unique_index_ext(), RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, root, RTE_RELATION, RTE_SUBQUERY, RelOptInfo::rtekind, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by is_innerrel_unique_for(), and join_is_removable().
|
static |
Definition at line 840 of file analyzejoins.c.
References RelOptInfo::indexlist, lfirst, NIL, query_supports_distinctness(), RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, root, RTE_RELATION, RTE_SUBQUERY, and RelOptInfo::rtekind.
Referenced by innerrel_is_unique_ext(), join_is_removable(), and reduce_unique_semijoins().
|
static |
Definition at line 483 of file analyzejoins.c.
References Assert, bms_add_member(), bms_add_members(), bms_is_member(), bms_union(), RestrictInfo::clause, SpecialJoinInfo::commute_above_r, SpecialJoinInfo::commute_below_l, distribute_restrictinfo_to_rels(), EquivalenceClass::ec_relids, find_base_rel(), RelOptInfo::joininfo, lfirst, list_copy(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, pfree(), pull_varnos(), remove_join_clause_from_rels(), remove_rel_from_eclass(), remove_rel_from_query(), remove_rel_from_restrictinfo(), RestrictInfo::required_relids, RINFO_IS_PUSHED_DOWN, and root.
Referenced by remove_useless_joins().
|
static |
Definition at line 656 of file analyzejoins.c.
References Assert, bms_del_member(), bms_is_empty, bms_is_member(), EquivalenceClass::ec_derives, EquivalenceClass::ec_members, EquivalenceClass::ec_relids, EquivalenceClass::ec_sources, EquivalenceMember::em_is_const, EquivalenceMember::em_relids, foreach_delete_current, lfirst, NIL, and remove_rel_from_restrictinfo().
Referenced by remove_leftjoinrel_from_query().
Definition at line 710 of file analyzejoins.c.
References elog, ERROR, IsA, lappend(), lfirst, NIL, and nodeTag.
Referenced by remove_useless_joins(), and remove_useless_self_joins().
|
static |
Definition at line 347 of file analyzejoins.c.
References Assert, bms_is_empty, bms_is_member(), bms_is_subset(), SpecialJoinInfo::commute_above_l, SpecialJoinInfo::commute_above_r, SpecialJoinInfo::commute_below_l, SpecialJoinInfo::commute_below_r, for(), foreach_delete_current, RelOptInfo::lateral_vars, lfirst, RelOptInfo::max_attr, RelOptInfo::min_attr, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_lateral, PlaceHolderInfo::ph_needed, PlaceHolderInfo::ph_var, PlaceHolderInfo::phid, PlaceHolderVar::phnullingrels, RelOptInfo::relid, replace_relid(), replace_varno(), root, SpecialJoinInfo::semi_rhs_exprs, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by remove_leftjoinrel_from_query(), and remove_self_join_rel().
|
static |
Definition at line 599 of file analyzejoins.c.
References Assert, bms_copy(), bms_del_member(), castNode, is_andclause(), is_orclause(), lfirst, lfirst_node, RestrictInfo::required_relids, and restriction_is_or_clause().
Referenced by remove_leftjoinrel_from_query(), and remove_rel_from_eclass().
|
static |
Definition at line 1747 of file analyzejoins.c.
References Assert, RelOptInfo::baserestrictinfo, bms_add_member(), bms_add_members(), bms_equal(), bms_is_member(), bms_membership(), BMS_MULTIPLE, bms_next_member(), distribute_restrictinfo_to_rels(), RelOptInfo::eclass_indexes, PathTarget::exprs, i, RelOptInfo::joininfo, lappend(), lfirst, lfirst_node, list_concat(), list_copy(), list_delete_ptr(), list_free(), list_member(), list_nth(), PlanRowMark::markType, RelOptInfo::min_attr, NIL, pfree(), PlanRowMark::prti, RelOptInfo::relid, RelOptInfo::reltarget, remove_join_clause_from_rels(), remove_rel_from_query(), replace_relid(), replace_varno(), RestrictInfo::required_relids, restrict_infos_logically_equal(), root, PlanRowMark::rti, and update_eclasses().
Referenced by remove_self_joins_one_group().
|
static |
Definition at line 2111 of file analyzejoins.c.
References Assert, RelOptInfo::baserestrictinfo, bms_add_member(), bms_is_member(), bms_next_member(), generate_join_implied_equalities(), innerrel_is_unique_ext(), JOIN_INNER, lfirst, list_concat(), list_length(), PlanRowMark::markType, match_unique_clauses(), NIL, RelOptInfo::relid, RelOptInfo::relids, remove_self_join_rel(), root, PlanRowMark::rti, split_selfjoin_quals(), SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by remove_self_joins_recurse().
|
static |
Definition at line 2279 of file analyzejoins.c.
References Assert, bms_add_member(), bms_add_members(), bms_del_member(), bms_del_members(), bms_free(), bms_is_empty, bms_is_member(), bms_membership(), BMS_MULTIPLE, bms_next_member(), bms_num_members(), bms_overlap(), elog, ERROR, i, IsA, j, lfirst, nodeTag, palloc(), qsort, SelfJoinCandidate::relid, SelfJoinCandidate::reloid, remove_self_joins_one_group(), root, RTE_RELATION, RangeTblEntry::rtekind, RangeTblRef::rtindex, and self_join_candidates_cmp().
Referenced by remove_useless_self_joins().
List* remove_useless_joins | ( | PlannerInfo * | root, |
List * | joinlist | ||
) |
Definition at line 81 of file analyzejoins.c.
References bms_singleton_member(), elog, ERROR, join_is_removable(), lfirst, list_delete_cell(), SpecialJoinInfo::min_righthand, remove_leftjoinrel_from_query(), remove_rel_from_joinlist(), and root.
Referenced by query_planner().
List* remove_useless_self_joins | ( | PlannerInfo * | root, |
List * | joinlist | ||
) |
Definition at line 2453 of file analyzejoins.c.
References bms_next_member(), enable_self_join_removal, IsA, linitial, list_length(), NIL, remove_rel_from_joinlist(), remove_self_joins_recurse(), root, and unlikely.
Referenced by query_planner().
Definition at line 1575 of file analyzejoins.c.
References bms_add_member(), bms_copy(), bms_del_member(), and bms_is_member().
Referenced by remove_rel_from_query(), remove_self_join_rel(), replace_varno_walker(), and update_eclasses().
|
static |
Definition at line 1547 of file analyzejoins.c.
References ReplaceVarnoContext::from, QTW_EXAMINE_SORTGROUP, query_or_expression_tree_walker, replace_varno_walker(), ReplaceVarnoContext::sublevels_up, and ReplaceVarnoContext::to.
Referenced by match_unique_clauses(), remove_rel_from_query(), remove_self_join_rel(), replace_varno_walker(), split_selfjoin_quals(), and update_eclasses().
|
static |
Definition at line 1442 of file analyzejoins.c.
References NullTest::arg, Assert, bms_get_singleton_member(), bms_is_member(), RestrictInfo::clause, equal(), expression_tree_walker, ReplaceVarnoContext::from, get_leftop(), get_rightop(), RestrictInfo::incompatible_relids, IS_NOT_NULL, IsA, NullTest::location, makeNode, NIL, NullTest::nulltesttype, RestrictInfo::outer_relids, PlaceHolderVar::phlevelsup, PlaceHolderVar::phnullingrels, QTW_EXAMINE_SORTGROUP, query_tree_walker, replace_relid(), replace_varno(), RestrictInfo::required_relids, ReplaceVarnoContext::sublevels_up, ReplaceVarnoContext::to, Var::varlevelsup, and Var::varno.
Referenced by replace_varno().
|
static |
|
static |
Definition at line 2406 of file analyzejoins.c.
References a, b, and SelfJoinCandidate::reloid.
Referenced by remove_self_joins_recurse().
|
static |
Definition at line 1976 of file analyzejoins.c.
References arg, OpExpr::args, bms_membership(), bms_num_members(), BMS_SINGLETON, bms_singleton_member(), RestrictInfo::clause, copyObject, equal(), get_leftop(), get_rightop(), if(), IsA, lappend(), lfirst_node, list_length(), NIL, and replace_varno().
Referenced by remove_self_joins_one_group().
|
static |
Definition at line 1614 of file analyzejoins.c.
References bms_is_member(), RestrictInfo::clause, EquivalenceClass::ec_derives, EquivalenceClass::ec_members, EquivalenceClass::ec_relids, EquivalenceClass::ec_sources, EquivalenceMember::em_expr, EquivalenceMember::em_jdomain, EquivalenceMember::em_relids, equal(), JoinDomain::jd_relids, lappend(), lfirst_node, list_free(), NIL, replace_relid(), replace_varno(), and RestrictInfo::required_relids.
Referenced by remove_self_join_rel().
bool enable_self_join_removal |
Definition at line 44 of file analyzejoins.c.
Referenced by remove_useless_self_joins().