PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/stratnum.h"
#include "catalog/pg_opfamily.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "partitioning/partbounds.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Definition at line 105 of file pathkeys.c.
References Assert(), lappend(), lfirst_node, NIL, pathkey_is_redundant(), and source.
Referenced by adjust_group_pathkeys_for_groupagg(), and make_pathkeys_for_window().
List* build_expression_pathkey | ( | PlannerInfo * | root, |
Expr * | expr, | ||
Oid | opno, | ||
Relids | rel, | ||
bool | create_it | ||
) |
Definition at line 801 of file pathkeys.c.
References BTGreaterStrategyNumber, elog(), ERROR, exprCollation(), get_ordering_op_properties(), list_make1, make_pathkey_from_sortinfo(), and NIL.
Referenced by set_function_pathlist().
List* build_index_pathkeys | ( | PlannerInfo * | root, |
IndexOptInfo * | index, | ||
ScanDirection | scandir | ||
) |
Definition at line 541 of file pathkeys.c.
References TargetEntry::expr, i, indexcol_is_bool_constant_for_query(), lappend(), lfirst, make_pathkey_from_sortinfo(), NIL, pathkey_is_redundant(), and ScanDirectionIsBackward.
Referenced by build_index_paths().
List* build_join_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | joinrel, | ||
JoinType | jointype, | ||
List * | outer_pathkeys | ||
) |
Definition at line 1095 of file pathkeys.c.
References JOIN_FULL, JOIN_RIGHT, JOIN_RIGHT_ANTI, NIL, and truncate_useless_pathkeys().
Referenced by consider_parallel_mergejoin(), consider_parallel_nestloop(), match_unsorted_outer(), and sort_inner_and_outer().
List* build_partition_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | partrel, | ||
ScanDirection | scandir, | ||
bool * | partialkeys | ||
) |
Definition at line 720 of file pathkeys.c.
References Assert(), i, IS_SIMPLE_REL, lappend(), linitial, RelOptInfo::live_parts, make_pathkey_from_sortinfo(), NIL, PartitionSchemeData::partcollation, partitions_are_ordered(), partkey_is_bool_constant_for_query(), PartitionSchemeData::partnatts, PartitionSchemeData::partopcintype, PartitionSchemeData::partopfamily, pathkey_is_redundant(), RelOptInfo::relids, and ScanDirectionIsBackward.
Referenced by generate_orderedappend_paths().
PathKeysComparison compare_pathkeys | ( | List * | keys1, |
List * | keys2 | ||
) |
Definition at line 301 of file pathkeys.c.
References forboth, lfirst, PATHKEYS_BETTER1, PATHKEYS_BETTER2, PATHKEYS_DIFFERENT, and PATHKEYS_EQUAL.
Referenced by add_partial_path(), add_partial_path_precheck(), add_path(), add_path_precheck(), add_paths_to_append_rel(), adjust_group_pathkeys_for_groupagg(), pathkeys_contained_in(), and set_cheapest().
List* convert_subquery_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | rel, | ||
List * | subquery_pathkeys, | ||
List * | subquery_tlist | ||
) |
Definition at line 855 of file pathkeys.c.
References Assert(), canonicalize_ec_expression(), EquivalenceClass::ec_collation, EquivalenceClass::ec_has_volatile, EquivalenceClass::ec_members, EquivalenceClass::ec_opfamilies, EquivalenceClass::ec_sortref, elog(), EquivalenceMember::em_datatype, EquivalenceMember::em_expr, EquivalenceMember::em_is_child, equal(), ERROR, TargetEntry::expr, find_var_for_subquery_tle(), get_eclass_for_sort_expr(), get_sortgroupref_tle(), i, j, lappend(), lfirst, linitial, list_length(), list_nth(), make_canonical_pathkey(), NIL, pathkey_is_redundant(), PathKey::pk_nulls_first, PathKey::pk_opfamily, PathKey::pk_strategy, PlannerInfo::query_pathkeys, and RelOptInfo::relids.
Referenced by set_subquery_pathlist().
List* find_mergeclauses_for_outer_pathkeys | ( | PlannerInfo * | root, |
List * | pathkeys, | ||
List * | restrictinfos | ||
) |
Definition at line 1313 of file pathkeys.c.
References i, j, lappend(), lfirst, list_concat(), NIL, and update_mergeclause_eclasses().
Referenced by generate_mergejoin_paths(), and sort_inner_and_outer().
|
static |
Definition at line 1052 of file pathkeys.c.
References Assert(), copyObject, PathTarget::exprs, IsA, lfirst, RelOptInfo::relid, RelOptInfo::reltarget, TargetEntry::resno, Var::varattno, and Var::varno.
Referenced by convert_subquery_pathkeys().
Path* get_cheapest_fractional_path_for_pathkeys | ( | List * | paths, |
List * | pathkeys, | ||
Relids | required_outer, | ||
double | fraction | ||
) |
Definition at line 467 of file pathkeys.c.
References bms_is_subset(), compare_fractional_path_costs(), lfirst, PATH_REQ_OUTER, Path::pathkeys, and pathkeys_contained_in().
Referenced by build_minmax_path(), and generate_orderedappend_paths().
Definition at line 500 of file pathkeys.c.
References bms_is_empty, lfirst, Path::parallel_safe, and PATH_REQ_OUTER.
Referenced by add_paths_to_append_rel(), hash_inner_and_outer(), match_unsorted_outer(), and sort_inner_and_outer().
Path* get_cheapest_path_for_pathkeys | ( | List * | paths, |
List * | pathkeys, | ||
Relids | required_outer, | ||
CostSelector | cost_criterion, | ||
bool | require_parallel_safe | ||
) |
Definition at line 421 of file pathkeys.c.
References bms_is_subset(), compare_path_costs(), lfirst, Path::parallel_safe, PATH_REQ_OUTER, Path::pathkeys, and pathkeys_contained_in().
Referenced by generate_mergejoin_paths(), generate_orderedappend_paths(), and get_cheapest_parameterized_child_path().
bool has_useful_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 1987 of file pathkeys.c.
References RelOptInfo::has_eclass_joins, RelOptInfo::joininfo, NIL, and PlannerInfo::query_pathkeys.
Referenced by build_child_join_rel(), build_index_paths(), and set_append_rel_size().
void initialize_mergeclause_eclasses | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 1232 of file pathkeys.c.
References Assert(), RestrictInfo::clause, get_eclass_for_sort_expr(), get_leftop(), get_rightop(), NIL, and op_input_types().
Referenced by distribute_qual_to_rels().
PathKey* make_canonical_pathkey | ( | PlannerInfo * | root, |
EquivalenceClass * | eclass, | ||
Oid | opfamily, | ||
int | strategy, | ||
bool | nulls_first | ||
) |
Definition at line 54 of file pathkeys.c.
References PlannerInfo::canon_pathkeys, PlannerInfo::ec_merging_done, eclass(), elog(), ERROR, lappend(), lfirst, makeNode, MemoryContextSwitchTo(), PathKey::pk_nulls_first, PathKey::pk_opfamily, and PathKey::pk_strategy.
Referenced by convert_subquery_pathkeys(), get_useful_pathkeys_for_relation(), make_inner_pathkeys_for_merge(), make_pathkey_from_sortinfo(), and select_outer_pathkeys_for_merge().
List* make_inner_pathkeys_for_merge | ( | PlannerInfo * | root, |
List * | mergeclauses, | ||
List * | outer_pathkeys | ||
) |
Definition at line 1624 of file pathkeys.c.
References elog(), ERROR, lappend(), lfirst, list_head(), lnext(), make_canonical_pathkey(), NIL, pathkey_is_redundant(), PathKey::pk_nulls_first, PathKey::pk_opfamily, PathKey::pk_strategy, and update_mergeclause_eclasses().
Referenced by generate_mergejoin_paths(), and sort_inner_and_outer().
|
static |
Definition at line 196 of file pathkeys.c.
References BTEqualStrategyNumber, BTGreaterStrategyNumber, BTLessStrategyNumber, eclass(), elog(), ERROR, get_eclass_for_sort_expr(), get_mergejoin_opfamilies(), get_opfamily_member(), make_canonical_pathkey(), and OidIsValid.
Referenced by build_expression_pathkey(), build_index_pathkeys(), build_partition_pathkeys(), and make_pathkey_from_sortop().
|
static |
Definition at line 254 of file pathkeys.c.
References BTGreaterStrategyNumber, elog(), ERROR, exprCollation(), get_ordering_op_properties(), and make_pathkey_from_sortinfo().
Referenced by make_pathkeys_for_sortclauses_extended().
List* make_pathkeys_for_sortclauses | ( | PlannerInfo * | root, |
List * | sortclauses, | ||
List * | tlist | ||
) |
Definition at line 1133 of file pathkeys.c.
References Assert(), and make_pathkeys_for_sortclauses_extended().
Referenced by adjust_group_pathkeys_for_groupagg(), generate_nonunion_paths(), grouping_planner(), make_pathkeys_for_window(), make_union_unique(), minmax_qp_callback(), and standard_qp_callback().
List* make_pathkeys_for_sortclauses_extended | ( | PlannerInfo * | root, |
List ** | sortclauses, | ||
List * | tlist, | ||
bool | remove_redundant, | ||
bool * | sortable | ||
) |
Definition at line 1170 of file pathkeys.c.
References foreach_delete_current, get_sortgroupclause_expr(), lappend(), lfirst, make_pathkey_from_sortop(), NIL, SortGroupClause::nulls_first, OidIsValid, pathkey_is_redundant(), SortGroupClause::sortop, and SortGroupClause::tleSortGroupRef.
Referenced by make_pathkeys_for_sortclauses(), make_pathkeys_for_window(), and standard_qp_callback().
|
static |
Definition at line 685 of file pathkeys.c.
References arg, RestrictInfo::clause, equal(), get_notclausearg(), is_notclause(), and linitial.
Referenced by partkey_is_bool_constant_for_query().
|
static |
Definition at line 645 of file pathkeys.c.
References RelOptInfo::baserestrictinfo, lfirst, matches_boolean_partition_clause(), and PartitionSchemeData::partopfamily.
Referenced by build_partition_pathkeys().
Definition at line 157 of file pathkeys.c.
References EC_MUST_BE_REDUNDANT, and lfirst.
Referenced by append_pathkeys(), build_index_pathkeys(), build_partition_pathkeys(), convert_subquery_pathkeys(), make_inner_pathkeys_for_merge(), make_pathkeys_for_sortclauses_extended(), and select_outer_pathkeys_for_merge().
Definition at line 340 of file pathkeys.c.
References compare_pathkeys(), PATHKEYS_BETTER2, and PATHKEYS_EQUAL.
Referenced by add_paths_with_pathkeys_for_rel(), adjust_foreign_grouping_path_cost(), consider_groupingsets_paths(), cost_append(), create_append_plan(), create_gather_merge_path(), create_gather_merge_plan(), create_merge_append_path(), create_merge_append_plan(), create_ordered_paths(), gather_grouping_paths(), generate_mergejoin_paths(), generate_orderedappend_paths(), get_cheapest_fractional_path_for_pathkeys(), get_cheapest_path_for_pathkeys(), try_mergejoin_path(), and try_partial_mergejoin_path().
Definition at line 359 of file pathkeys.c.
References forboth, lfirst, list_length(), and NIL.
Referenced by add_paths_to_grouping_rel(), create_final_distinct_paths(), create_one_window_path(), create_ordered_paths(), create_partial_distinct_paths(), create_partial_grouping_paths(), create_window_paths(), gather_grouping_paths(), generate_useful_gather_paths(), and pathkeys_useful_for_ordering().
|
static |
Definition at line 1822 of file pathkeys.c.
References eclass_useful_for_merging(), RelOptInfo::has_eclass_joins, i, j, RelOptInfo::joininfo, lfirst, NIL, right_merge_direction(), and update_mergeclause_eclasses().
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 1926 of file pathkeys.c.
References NIL, pathkeys_count_contained_in(), and PlannerInfo::query_pathkeys.
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 1889 of file pathkeys.c.
References BTLessStrategyNumber, lfirst, PathKey::pk_opfamily, PathKey::pk_strategy, and PlannerInfo::query_pathkeys.
Referenced by pathkeys_useful_for_merging().
List* select_outer_pathkeys_for_merge | ( | PlannerInfo * | root, |
List * | mergeclauses, | ||
RelOptInfo * | joinrel | ||
) |
Definition at line 1428 of file pathkeys.c.
References Assert(), bms_overlap(), BTLessStrategyNumber, EquivalenceClass::ec_members, EquivalenceClass::ec_opfamilies, EquivalenceMember::em_is_child, EquivalenceMember::em_is_const, EquivalenceMember::em_relids, j, lappend(), lfirst, linitial_oid, list_copy(), list_copy_head(), list_length(), make_canonical_pathkey(), NIL, palloc(), pathkey_is_redundant(), pfree(), PlannerInfo::query_pathkeys, RelOptInfo::relids, and update_mergeclause_eclasses().
Referenced by sort_inner_and_outer().
List* trim_mergeclauses_for_inner_pathkeys | ( | PlannerInfo * | root, |
List * | mergeclauses, | ||
List * | pathkeys | ||
) |
Definition at line 1727 of file pathkeys.c.
References i, lappend(), lfirst, list_head(), lnext(), and NIL.
Referenced by generate_mergejoin_paths().
List* truncate_useless_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | rel, | ||
List * | pathkeys | ||
) |
Definition at line 1947 of file pathkeys.c.
References list_copy_head(), list_length(), NIL, pathkeys_useful_for_merging(), and pathkeys_useful_for_ordering().
Referenced by build_index_paths(), and build_join_pathkeys().
void update_mergeclause_eclasses | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 1279 of file pathkeys.c.
Referenced by find_mergeclauses_for_outer_pathkeys(), get_useful_ecs_for_relation(), make_inner_pathkeys_for_merge(), pathkeys_useful_for_merging(), select_mergejoin_clauses(), and select_outer_pathkeys_for_merge().