PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/appendinfo.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/inherit.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/placeholder.h"
#include "optimizer/plancat.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/parse_relation.h"
#include "rewrite/rewriteManip.h"
#include "utils/hsearch.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Data Structures | |
struct | JoinHashEntry |
Typedefs | |
typedef struct JoinHashEntry | JoinHashEntry |
typedef struct JoinHashEntry JoinHashEntry |
|
static |
Definition at line 627 of file relnode.c.
References Assert, HASH_ENTER, hash_search(), JoinHashEntry::join_rel, lappend(), RelOptInfo::relids, and root.
Referenced by build_child_join_rel(), and build_join_rel().
RelOptInfo* build_child_join_rel | ( | PlannerInfo * | root, |
RelOptInfo * | outer_rel, | ||
RelOptInfo * | inner_rel, | ||
RelOptInfo * | parent_joinrel, | ||
List * | restrictlist, | ||
SpecialJoinInfo * | sjinfo, | ||
int | nappinfos, | ||
AppendRelInfo ** | appinfos | ||
) |
Definition at line 882 of file relnode.c.
References add_child_join_rel_equivalences(), add_join_rel(), adjust_appendrel_attrs(), adjust_child_relids(), RelOptInfo::all_partrels, RelOptInfo::allvisfrac, RelOptInfo::amflags, Assert, RelOptInfo::baserestrictcost, RelOptInfo::baserestrictinfo, bms_copy(), build_child_join_reltarget(), build_joinrel_partition_info(), RelOptInfo::cheapest_parameterized_paths, RelOptInfo::cheapest_startup_path, RelOptInfo::cheapest_total_path, RelOptInfo::cheapest_unique_path, RelOptInfo::consider_parallel, RelOptInfo::consider_param_startup, RelOptInfo::consider_partitionwise_join, RelOptInfo::consider_startup, create_empty_pathtarget(), RelOptInfo::direct_lateral_relids, RelOptInfo::eclass_indexes, find_join_rel(), RelOptInfo::has_eclass_joins, has_useful_pathkeys(), RelOptInfo::indexlist, InvalidOid, IS_OTHER_REL, RelOptInfo::joininfo, RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, RelOptInfo::live_parts, makeNode, RelOptInfo::max_attr, RelOptInfo::min_attr, NIL, RelOptInfo::notnullattnums, RelOptInfo::nparts, RelOptInfo::nulling_relids, RelOptInfo::pages, RelOptInfo::partbounds_merged, RelOptInfo::partial_pathlist, RelOptInfo::partition_qual, RelOptInfo::pathlist, QualCost::per_tuple, RelOptInfo::ppilist, RelOptInfo::relid, RelOptInfo::relids, RELOPT_OTHER_JOINREL, RelOptInfo::reloptkind, RelOptInfo::reltarget, root, RelOptInfo::rows, RTE_JOIN, RelOptInfo::rtekind, RelOptInfo::serverid, set_foreign_rel_properties(), set_joinrel_size_estimates(), QualCost::startup, RelOptInfo::subplan_params, RelOptInfo::subroot, RelOptInfo::top_parent_relids, RelOptInfo::tuples, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by try_partitionwise_join().
|
static |
Definition at line 2518 of file relnode.c.
References adjust_appendrel_attrs(), PathTarget::cost, PathTarget::exprs, QualCost::per_tuple, RelOptInfo::reltarget, root, QualCost::startup, and PathTarget::width.
Referenced by build_child_join_rel().
RelOptInfo* build_join_rel | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
RelOptInfo * | outer_rel, | ||
RelOptInfo * | inner_rel, | ||
SpecialJoinInfo * | sjinfo, | ||
List * | pushed_down_joins, | ||
List ** | restrictlist_ptr | ||
) |
Definition at line 665 of file relnode.c.
References add_join_rel(), add_placeholders_to_joinrel(), RelOptInfo::all_partrels, RelOptInfo::allvisfrac, RelOptInfo::amflags, Assert, RelOptInfo::baserestrict_min_security, RelOptInfo::baserestrictcost, RelOptInfo::baserestrictinfo, bms_copy(), bms_del_members(), bms_num_members(), bms_union(), build_joinrel_joinlist(), build_joinrel_partition_info(), build_joinrel_restrictlist(), build_joinrel_tlist(), RelOptInfo::cheapest_parameterized_paths, RelOptInfo::cheapest_startup_path, RelOptInfo::cheapest_total_path, RelOptInfo::cheapest_unique_path, RelOptInfo::consider_parallel, RelOptInfo::consider_param_startup, RelOptInfo::consider_partitionwise_join, RelOptInfo::consider_startup, create_empty_pathtarget(), RelOptInfo::direct_lateral_relids, RelOptInfo::eclass_indexes, PathTarget::exprs, find_join_rel(), RelOptInfo::has_eclass_joins, has_relevant_eclass_joinclause(), RelOptInfo::indexlist, InvalidOid, IS_OTHER_REL, is_parallel_safe(), JOIN_FULL, JOIN_INNER, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lappend(), RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, RelOptInfo::live_parts, makeNode, RelOptInfo::max_attr, RelOptInfo::min_attr, min_join_parameterization(), NIL, RelOptInfo::non_unique_for_rels, RelOptInfo::notnullattnums, RelOptInfo::nparts, RelOptInfo::nulling_relids, RelOptInfo::pages, RelOptInfo::partbounds_merged, RelOptInfo::partial_pathlist, RelOptInfo::partition_qual, RelOptInfo::pathlist, QualCost::per_tuple, RelOptInfo::ppilist, RelOptInfo::rel_parallel_workers, RelOptInfo::relid, RelOptInfo::relids, RELOPT_JOINREL, RelOptInfo::reloptkind, RelOptInfo::reltarget, root, RelOptInfo::rows, RTE_JOIN, RelOptInfo::rtekind, RelOptInfo::serverid, set_foreign_rel_properties(), set_joinrel_size_estimates(), QualCost::startup, RelOptInfo::statlist, RelOptInfo::subplan_params, RelOptInfo::subroot, RelOptInfo::top_parent_relids, RelOptInfo::tuples, RelOptInfo::unique_for_rels, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by make_join_rel().
|
static |
Definition at line 486 of file relnode.c.
References Assert, bitmap_hash(), bitmap_match(), CurrentMemoryContext, HASHCTL::entrysize, HASHCTL::hash, HASH_COMPARE, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, HASH_FUNCTION, hash_search(), HASHCTL::hcxt, JoinHashEntry::join_rel, HASHCTL::keysize, lfirst, HASHCTL::match, RelOptInfo::relids, and root.
Referenced by find_join_rel().
|
static |
Definition at line 1322 of file relnode.c.
References RelOptInfo::joininfo, NIL, and subbuild_joinrel_joinlist().
Referenced by build_join_rel().
|
static |
Definition at line 2005 of file relnode.c.
References Assert, RelOptInfo::consider_partitionwise_join, enable_partitionwise_join, have_partkey_equi_join(), IS_PARTITIONED_REL, SpecialJoinInfo::jointype, root, and set_joinrel_partition_key_exprs().
Referenced by build_child_join_rel(), and build_join_rel().
|
static |
Definition at line 1285 of file relnode.c.
References bms_union(), generate_join_implied_equalities(), list_concat(), NIL, RelOptInfo::relids, root, and subbuild_joinrel_restrictlist().
Referenced by build_join_rel().
|
static |
Definition at line 1100 of file relnode.c.
References Assert, bms_add_member(), bms_intersect(), bms_is_member(), bms_is_subset(), bms_join(), bms_nonempty_difference(), clamp_width_est(), SpecialJoinInfo::commute_above_r, copyObject, elog, ERROR, PathTarget::exprs, find_base_rel(), find_placeholder_info(), IsA, JOIN_FULL, SpecialJoinInfo::jointype, lappend(), lfirst, list_nth(), RelOptInfo::min_attr, nodeTag, SpecialJoinInfo::ojrelid, PlaceHolderInfo::ph_needed, PlaceHolderInfo::ph_width, PlaceHolderVar::phnullingrels, RelOptInfo::relids, RelOptInfo::reltarget, root, ROWID_VAR, RowIdentityVarInfo::rowidwidth, SpecialJoinInfo::syn_lefthand, SpecialJoinInfo::syn_righthand, Var::varattno, Var::varno, and PathTarget::width.
Referenced by build_join_rel().
RelOptInfo* build_simple_rel | ( | PlannerInfo * | root, |
int | relid, | ||
RelOptInfo * | parent | ||
) |
Definition at line 192 of file relnode.c.
References RelOptInfo::all_partrels, RelOptInfo::allvisfrac, RelOptInfo::amflags, apply_child_basequals(), Assert, RelOptInfo::baserestrict_min_security, RelOptInfo::baserestrictcost, RelOptInfo::baserestrictinfo, bms_make_singleton(), RelOptInfo::cheapest_parameterized_paths, RelOptInfo::cheapest_startup_path, RelOptInfo::cheapest_total_path, RelOptInfo::cheapest_unique_path, RTEPermissionInfo::checkAsUser, RelOptInfo::consider_parallel, RelOptInfo::consider_param_startup, RelOptInfo::consider_partitionwise_join, RelOptInfo::consider_startup, create_empty_pathtarget(), RelOptInfo::direct_lateral_relids, RelOptInfo::eclass_indexes, elog, ERROR, get_relation_info(), getRTEPermissionInfo(), RelOptInfo::has_eclass_joins, RelOptInfo::indexlist, RangeTblEntry::inh, InvalidOid, RelOptInfo::joininfo, RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, list_length(), RelOptInfo::live_parts, makeNode, mark_dummy_rel(), RelOptInfo::max_attr, RelOptInfo::min_attr, NIL, RelOptInfo::non_unique_for_rels, RelOptInfo::notnullattnums, RelOptInfo::nparts, RelOptInfo::nulling_relids, RelOptInfo::pages, palloc0(), RelOptInfo::partbounds_merged, RelOptInfo::partial_pathlist, RelOptInfo::partition_qual, RelOptInfo::pathlist, QualCost::per_tuple, RelOptInfo::ppilist, RelOptInfo::rel_parallel_workers, RangeTblEntry::relid, RelOptInfo::relid, RelOptInfo::relids, RELOPT_BASEREL, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, RelOptInfo::reltarget, root, RelOptInfo::rows, RTE_CTE, RTE_FUNCTION, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RelOptInfo::rtekind, RelOptInfo::serverid, QualCost::startup, RelOptInfo::statlist, RelOptInfo::subplan_params, RelOptInfo::subroot, RelOptInfo::top_parent_relids, RelOptInfo::tuples, RelOptInfo::unique_for_rels, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by add_base_rels_to_query(), expand_appendrel_subquery(), expand_inherited_rtentry(), expand_partitioned_rtentry(), plan_cluster_use_sort(), plan_create_index_workers(), query_planner(), and recurse_set_operations().
void expand_planner_arrays | ( | PlannerInfo * | root, |
int | add_size | ||
) |
Definition at line 163 of file relnode.c.
References add_size(), Assert, palloc0_array, repalloc0_array, and root.
Referenced by expand_inherited_rtentry(), and expand_partitioned_rtentry().
RelOptInfo* fetch_upper_rel | ( | PlannerInfo * | root, |
UpperRelationKind | kind, | ||
Relids | relids | ||
) |
Definition at line 1458 of file relnode.c.
References bms_copy(), bms_equal(), RelOptInfo::cheapest_parameterized_paths, RelOptInfo::cheapest_startup_path, RelOptInfo::cheapest_total_path, RelOptInfo::cheapest_unique_path, RelOptInfo::consider_parallel, RelOptInfo::consider_param_startup, RelOptInfo::consider_startup, create_empty_pathtarget(), lappend(), lfirst, makeNode, NIL, RelOptInfo::pathlist, RelOptInfo::relids, RELOPT_UPPER_REL, RelOptInfo::reloptkind, RelOptInfo::reltarget, and root.
Referenced by add_rtes_to_flat_rtable(), build_setop_child_paths(), create_distinct_paths(), create_ordered_paths(), create_partial_distinct_paths(), create_partial_grouping_paths(), create_window_paths(), generate_nonunion_paths(), generate_recursion_path(), generate_union_paths(), grouping_planner(), make_grouping_rel(), make_subplan(), preprocess_minmax_aggregates(), set_subquery_pathlist(), set_subquery_size_estimates(), SS_process_ctes(), standard_planner(), and subquery_planner().
RelOptInfo* find_base_rel | ( | PlannerInfo * | root, |
int | relid | ||
) |
Definition at line 414 of file relnode.c.
References elog, ERROR, and root.
Referenced by add_base_clause_to_rel(), add_placeholders_to_base_rels(), add_vars_to_attr_needed(), add_vars_to_targetlist(), build_joinrel_tlist(), clause_selectivity_ext(), create_lateral_join_info(), distribute_row_identity_vars(), examine_simple_variable(), examine_variable(), expr_is_nonnullable(), finalize_plan(), find_childrel_parents(), find_join_input_rel(), find_single_rel_for_clauses(), get_foreign_key_join_selectivity(), get_matching_part_pairs(), get_rel_all_updated_cols(), get_translated_update_targetlist(), grouping_planner(), join_is_removable(), make_partition_pruneinfo(), make_partitionedrel_pruneinfo(), make_rel_from_joinlist(), postgresPlanForeignModify(), reduce_unique_semijoins(), remove_rel_from_query(), set_append_rel_size(), set_base_rel_consider_startup(), set_subquery_size_estimates(), and set_subqueryscan_references().
RelOptInfo* find_base_rel_ignore_join | ( | PlannerInfo * | root, |
int | relid | ||
) |
Definition at line 454 of file relnode.c.
References elog, ERROR, JOIN_INNER, RangeTblEntry::jointype, root, RTE_JOIN, and RangeTblEntry::rtekind.
Referenced by add_join_clause_to_rels(), create_lateral_join_info(), find_appinfos_by_relids(), and remove_join_clause_from_rels().
RelOptInfo* find_base_rel_noerr | ( | PlannerInfo * | root, |
int | relid | ||
) |
Relids find_childrel_parents | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 1509 of file relnode.c.
References Assert, bms_add_member(), find_base_rel(), AppendRelInfo::parent_relid, RelOptInfo::relid, RELOPT_BASEREL, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, and root.
Referenced by check_index_predicates(), and generate_implied_equalities_for_column().
RelOptInfo* find_join_rel | ( | PlannerInfo * | root, |
Relids | relids | ||
) |
Definition at line 527 of file relnode.c.
References bms_equal(), build_join_rel_hash(), HASH_FIND, hash_search(), JoinHashEntry::join_rel, lfirst, list_length(), RelOptInfo::relids, and root.
Referenced by build_child_join_rel(), build_join_rel(), examine_variable(), find_join_input_rel(), get_matching_part_pairs(), and postgresPlanDirectModify().
ParamPathInfo* find_param_path_info | ( | RelOptInfo * | rel, |
Relids | required_outer | ||
) |
Definition at line 1889 of file relnode.c.
References bms_equal(), lfirst, ParamPathInfo::ppi_req_outer, and RelOptInfo::ppilist.
Referenced by get_appendrel_parampathinfo(), get_baserel_parampathinfo(), get_joinrel_parampathinfo(), and reparameterize_path_by_child().
ParamPathInfo* get_appendrel_parampathinfo | ( | RelOptInfo * | appendrel, |
Relids | required_outer | ||
) |
Definition at line 1856 of file relnode.c.
References Assert, bms_is_empty, bms_is_subset(), bms_overlap(), find_param_path_info(), lappend(), RelOptInfo::lateral_relids, makeNode, NIL, ParamPathInfo::ppi_clauses, ParamPathInfo::ppi_req_outer, ParamPathInfo::ppi_rows, ParamPathInfo::ppi_serials, RelOptInfo::ppilist, and RelOptInfo::relids.
Referenced by create_append_path().
ParamPathInfo* get_baserel_parampathinfo | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
Relids | required_outer | ||
) |
Definition at line 1545 of file relnode.c.
References Assert, bms_add_member(), bms_is_empty, bms_is_subset(), bms_overlap(), bms_union(), find_param_path_info(), generate_join_implied_equalities(), get_parameterized_baserel_size(), join_clause_is_movable_into(), RelOptInfo::joininfo, lappend(), RelOptInfo::lateral_relids, lfirst, list_concat(), makeNode, NIL, ParamPathInfo::ppi_clauses, ParamPathInfo::ppi_req_outer, ParamPathInfo::ppi_rows, ParamPathInfo::ppi_serials, RelOptInfo::ppilist, RelOptInfo::relids, RestrictInfo::rinfo_serial, and root.
Referenced by create_append_path(), create_bitmap_and_path(), create_bitmap_heap_path(), create_bitmap_or_path(), create_ctescan_path(), create_foreignscan_path(), create_functionscan_path(), create_gather_merge_path(), create_gather_path(), create_index_path(), create_namedtuplestorescan_path(), create_resultscan_path(), create_samplescan_path(), create_seqscan_path(), create_subqueryscan_path(), create_tablefuncscan_path(), create_tidrangescan_path(), create_tidscan_path(), create_valuesscan_path(), create_worktablescan_path(), postgresGetForeignPaths(), and reparameterize_path().
ParamPathInfo* get_joinrel_parampathinfo | ( | PlannerInfo * | root, |
RelOptInfo * | joinrel, | ||
Path * | outer_path, | ||
Path * | inner_path, | ||
SpecialJoinInfo * | sjinfo, | ||
Relids | required_outer, | ||
List ** | restrict_clauses | ||
) |
Definition at line 1659 of file relnode.c.
References Assert, bms_is_empty, bms_is_subset(), bms_overlap(), bms_union(), find_param_path_info(), generate_join_implied_equalities(), generate_join_implied_equalities_for_ecs(), get_parameterized_joinrel_size(), join_clause_is_movable_into(), RelOptInfo::joininfo, lappend(), RelOptInfo::lateral_relids, lfirst, list_concat(), makeNode, NIL, PATH_REQ_OUTER, ParamPathInfo::ppi_clauses, ParamPathInfo::ppi_req_outer, ParamPathInfo::ppi_rows, ParamPathInfo::ppi_serials, RelOptInfo::ppilist, RelOptInfo::relids, and root.
Referenced by create_hashjoin_path(), create_mergejoin_path(), and create_nestloop_path().
Definition at line 1910 of file relnode.c.
References bms_add_member(), bms_add_members(), bms_copy(), bms_int_members(), JoinPath::innerjoinpath, IsA, JoinPath::joinrestrictinfo, lfirst, list_head(), JoinPath::outerjoinpath, RestrictInfo::rinfo_serial, subpath(), AppendPath::subpaths, and MergeAppendPath::subpaths.
Referenced by create_nestloop_path().
|
static |
Definition at line 2078 of file relnode.c.
References OpExpr::args, Assert, bms_is_subset(), bms_overlap(), castNode, RestrictInfo::clause, exprCollation(), exprs_known_equal(), get_mergejoin_opfamilies(), get_opfamily_member(), HTEqualStrategyNumber, IS_OUTER_JOIN, lfirst, lfirst_node, linitial, linitial_oid, list_member_oid(), lsecond, match_expr_to_partition_keys(), NIL, OidIsValid, op_in_opfamily(), op_strict(), OpExpr::opno, PARTITION_MAX_KEYS, PARTITION_STRATEGY_HASH, PartitionSchemeData::partnatts, PartitionSchemeData::partopcintype, PartitionSchemeData::partopfamily, PG_USED_FOR_ASSERTS_ONLY, RelOptInfo::relids, remove_nulling_relids(), RINFO_IS_PUSHED_DOWN, root, and PartitionSchemeData::strategy.
Referenced by build_joinrel_partition_info().
|
static |
Definition at line 2325 of file relnode.c.
References arg, Assert, castNode, equal(), IsA, and lfirst.
Referenced by have_partkey_equi_join().
Relids min_join_parameterization | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
RelOptInfo * | outer_rel, | ||
RelOptInfo * | inner_rel | ||
) |
Definition at line 1022 of file relnode.c.
References bms_del_members(), bms_union(), and RelOptInfo::lateral_relids.
Referenced by build_join_rel(), and join_is_legal().
|
static |
Definition at line 589 of file relnode.c.
References GetUserId(), OidIsValid, RelOptInfo::serverid, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by build_child_join_rel(), and build_join_rel().
|
static |
Definition at line 2374 of file relnode.c.
References elog, ERROR, exprCollation(), exprType(), JOIN_ANTI, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, lappend(), lfirst, list_concat(), list_concat_copy(), list_copy(), list_make2, makeNode, NIL, palloc0(), and PartitionSchemeData::partnatts.
Referenced by build_joinrel_partition_info().
void setup_simple_rel_arrays | ( | PlannerInfo * | root | ) |
Definition at line 94 of file relnode.c.
References Assert, AppendRelInfo::child_relid, elog, ERROR, lfirst, lfirst_node, list_length(), NIL, palloc0(), root, and size.
Referenced by plan_cluster_use_sort(), plan_create_index_workers(), plan_set_operations(), and query_planner().
|
static |
Definition at line 1406 of file relnode.c.
References Assert, bms_is_subset(), lfirst, list_append_unique_ptr(), RelOptInfo::relids, RELOPT_JOINREL, RelOptInfo::reloptkind, and RestrictInfo::required_relids.
Referenced by build_joinrel_joinlist().
|
static |
Definition at line 1340 of file relnode.c.
References Assert, bms_is_subset(), bms_overlap(), RestrictInfo::has_clone, RestrictInfo::incompatible_relids, RestrictInfo::is_clone, RelOptInfo::joininfo, lfirst, list_append_unique_ptr(), RelOptInfo::relids, RestrictInfo::required_relids, and RINFO_IS_PUSHED_DOWN.
Referenced by build_joinrel_restrictlist().