|
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/placeholder.h"#include "optimizer/planmain.h"#include "optimizer/restrictinfo.h"#include "parser/parse_agg.h"#include "rewrite/rewriteManip.h"#include "utils/lsyscache.h"
Go to the source code of this file.
Data Structures | |
| struct | SelfJoinCandidate |
Variables | |
| bool | enable_self_join_elimination |
|
static |
Definition at line 1659 of file analyzejoins.c.
References Assert, bms_equal(), bms_is_member(), distribute_restrictinfo_to_rels(), fb(), foreach_node, restrict_infos_logically_equal(), and root.
Referenced by remove_self_join_rel().
Definition at line 1270 of file analyzejoins.c.
References fb(), 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 1310 of file analyzejoins.c.
References fb(), 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 1332 of file analyzejoins.c.
References bms_copy(), bms_equal(), bms_is_subset(), fb(), is_innerrel_unique_for(), lappend(), lfirst, makeNode, MemoryContextSwitchTo(), NIL, RelOptInfo::non_unique_for_rels, rel_supports_distinctness(), root, and RelOptInfo::unique_for_rels.
Referenced by innerrel_is_unique(), and remove_self_joins_one_group().
|
static |
Definition at line 1459 of file analyzejoins.c.
References clause_sides_match_join(), fb(), 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 156 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(), fb(), find_base_rel(), JOIN_LEFT, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lappend(), lfirst, RelOptInfo::max_attr, RelOptInfo::min_attr, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, NIL, SpecialJoinInfo::ojrelid, 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 2075 of file analyzejoins.c.
References Assert, bms_is_empty, ChangeVarNodesExtended(), copyObject, equal(), fb(), foreach_node, get_leftop(), get_rightop(), is_opclause(), NIL, and replace_relid_callback().
Referenced by remove_self_joins_one_group().
Definition at line 1117 of file analyzejoins.c.
References Assert, castNode, distinct_col_search(), Query::distinctClause, equality_ops_are_compatible(), expand_grouping_sets(), fb(), get_sortgroupclause_tle(), Query::groupClause, Query::groupDistinct, Query::groupingSets, Query::havingQual, lfirst, list_head(), list_length(), lnext(), OidIsValid, SETOP_NONE, Query::setOperations, and Query::targetList.
Referenced by rel_is_distinct_for().
Definition at line 1079 of file analyzejoins.c.
References Query::distinctClause, Query::groupClause, Query::groupingSets, Query::havingQual, NIL, and Query::setOperations.
Referenced by rel_supports_distinctness().
| void reduce_unique_semijoins | ( | PlannerInfo * | root | ) |
Definition at line 845 of file analyzejoins.c.
References Assert, bms_get_singleton_member(), bms_union(), fb(), 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 981 of file analyzejoins.c.
References castNode, RestrictInfo::clause, fb(), get_leftop(), get_rightop(), IsA, lappend_int(), lappend_oid(), lfirst_node, NIL, query_is_distinct_for(), relation_has_unique_index_for(), 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 921 of file analyzejoins.c.
References fb(), 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 545 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(), fb(), find_base_rel(), RelOptInfo::joininfo, lfirst, list_copy(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, pfree(), pull_varnos(), rebuild_eclass_attr_needed(), rebuild_joinclause_attr_needed(), rebuild_lateral_attr_needed(), rebuild_placeholder_attr_needed(), remove_join_clause_from_rels(), 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 720 of file analyzejoins.c.
References adjust_relid_set(), Assert, bms_is_empty, bms_is_member(), ChangeVarNodesExtended(), EquivalenceClass::ec_childmembers, ec_clear_derived_clauses(), EquivalenceClass::ec_members, EquivalenceClass::ec_relids, EquivalenceClass::ec_sources, fb(), foreach_delete_current, lfirst, SpecialJoinInfo::ojrelid, remove_rel_from_restrictinfo(), and replace_relid_callback().
Referenced by remove_rel_from_query().
Definition at line 791 of file analyzejoins.c.
References elog, ERROR, fb(), IsA, lappend(), lfirst, NIL, nodeTag, and remove_rel_from_joinlist().
Referenced by remove_rel_from_joinlist(), remove_useless_joins(), and remove_useless_self_joins().
|
static |
Definition at line 326 of file analyzejoins.c.
References adjust_relid_set(), Assert, bms_copy(), bms_del_member(), bms_difference(), bms_is_empty, bms_is_member(), bms_is_subset(), bms_make_singleton(), ChangeVarNodesExtended(), EquivalenceClass::ec_relids, fb(), foreach_delete_current, lfirst, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::ojrelid, RelOptInfo::relid, remove_rel_from_eclass(), replace_relid_callback(), and root.
Referenced by remove_leftjoinrel_from_query(), and remove_self_join_rel().
|
static |
Definition at line 659 of file analyzejoins.c.
References Assert, bms_copy(), bms_del_member(), castNode, fb(), is_andclause(), is_orclause(), lfirst, lfirst_node, remove_rel_from_restrictinfo(), RestrictInfo::required_relids, and restriction_is_or_clause().
Referenced by remove_leftjoinrel_from_query(), remove_rel_from_eclass(), and remove_rel_from_restrictinfo().
|
static |
Definition at line 1827 of file analyzejoins.c.
References add_non_redundant_clauses(), adjust_relid_set(), Assert, bms_add_member(), bms_add_members(), bms_membership(), BMS_MULTIPLE, bms_next_member(), ChangeVarNodesExtended(), fb(), foreach_node, i, lappend(), lfirst, list_concat(), list_copy(), list_delete_ptr(), list_free(), list_member(), list_nth(), NIL, pfree(), rebuild_eclass_attr_needed(), rebuild_joinclause_attr_needed(), rebuild_lateral_attr_needed(), rebuild_placeholder_attr_needed(), remove_join_clause_from_rels(), remove_rel_from_query(), replace_relid_callback(), root, and update_eclasses().
Referenced by remove_self_joins_one_group().
|
static |
Definition at line 2141 of file analyzejoins.c.
References Assert, bms_add_member(), bms_is_member(), bms_next_member(), fb(), generate_join_implied_equalities(), innerrel_is_unique_ext(), JOIN_INNER, lfirst, list_concat(), list_length(), match_unique_clauses(), NIL, remove_self_join_rel(), root, split_selfjoin_quals(), SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by remove_self_joins_recurse().
|
static |
Definition at line 2308 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, fb(), i, IsA, j, lfirst, nodeTag, palloc_array, qsort, remove_self_joins_one_group(), remove_self_joins_recurse(), root, RTE_RELATION, and self_join_candidates_cmp().
Referenced by remove_self_joins_recurse(), and remove_useless_self_joins().
| List * remove_useless_joins | ( | PlannerInfo * | root, |
| List * | joinlist | ||
| ) |
Definition at line 91 of file analyzejoins.c.
References bms_singleton_member(), elog, ERROR, fb(), 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 2488 of file analyzejoins.c.
References bms_next_member(), elog, enable_self_join_elimination, ERROR, fb(), IsA, linitial, list_length(), NIL, remove_rel_from_joinlist(), remove_self_joins_recurse(), root, and unlikely.
Referenced by query_planner().
|
static |
Definition at line 1703 of file analyzejoins.c.
References adjust_relid_set(), Assert, bms_get_singleton_member(), bms_is_member(), bms_membership(), BMS_MULTIPLE, bms_num_members(), ChangeVarNodesWalkExpression(), RestrictInfo::clause, equal(), fb(), get_leftop(), get_rightop(), RestrictInfo::incompatible_relids, IS_NOT_NULL, IsA, makeNode, ChangeVarNodes_context::new_index, NIL, RestrictInfo::outer_relids, RestrictInfo::required_relids, and ChangeVarNodes_context::rt_index.
Referenced by match_unique_clauses(), remove_rel_from_eclass(), remove_rel_from_query(), remove_self_join_rel(), split_selfjoin_quals(), and update_eclasses().
|
static |
Definition at line 1633 of file analyzejoins.c.
References a, b, equal(), and fb().
Referenced by add_non_redundant_clauses().
Definition at line 2441 of file analyzejoins.c.
References a, b, fb(), and SelfJoinCandidate::reloid.
Referenced by remove_self_joins_recurse().
|
static |
Definition at line 2010 of file analyzejoins.c.
References arg, OpExpr::args, bms_membership(), bms_num_members(), BMS_SINGLETON, bms_singleton_member(), ChangeVarNodesExtended(), copyObject, equal(), fb(), foreach_node, get_leftop(), get_rightop(), IsA, lappend(), list_length(), NIL, and replace_relid_callback().
Referenced by remove_self_joins_one_group().
|
static |
Definition at line 1533 of file analyzejoins.c.
References adjust_relid_set(), Assert, bms_is_member(), ChangeVarNodesExtended(), EquivalenceClass::ec_childmembers, ec_clear_derived_clauses(), EquivalenceClass::ec_members, EquivalenceClass::ec_relids, EquivalenceClass::ec_sources, equal(), fb(), foreach_node, lappend(), list_free(), NIL, and replace_relid_callback().
Referenced by remove_self_join_rel().
| bool enable_self_join_elimination |
Definition at line 54 of file analyzejoins.c.
Referenced by remove_useless_self_joins().