PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/stratnum.h"
#include "catalog/pg_opfamily.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "partitioning/partbounds.h"
#include "rewrite/rewriteManip.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Variables | |
bool | enable_group_by_reordering = true |
Definition at line 107 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 1000 of file pathkeys.c.
References BTGreaterStrategyNumber, elog, ERROR, exprCollation(), get_ordering_op_properties(), list_make1, make_pathkey_from_sortinfo(), NIL, and root.
Referenced by set_function_pathlist().
List* build_index_pathkeys | ( | PlannerInfo * | root, |
IndexOptInfo * | index, | ||
ScanDirection | scandir | ||
) |
Definition at line 740 of file pathkeys.c.
References TargetEntry::expr, i, indexcol_is_bool_constant_for_query(), lappend(), lfirst, make_pathkey_from_sortinfo(), NIL, pathkey_is_redundant(), root, and ScanDirectionIsBackward.
Referenced by build_index_paths().
List* build_join_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | joinrel, | ||
JoinType | jointype, | ||
List * | outer_pathkeys | ||
) |
Definition at line 1294 of file pathkeys.c.
References Assert, JOIN_FULL, JOIN_RIGHT, JOIN_RIGHT_ANTI, JOIN_RIGHT_SEMI, NIL, root, 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 919 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, root, and ScanDirectionIsBackward.
Referenced by generate_orderedappend_paths().
PathKeysComparison compare_pathkeys | ( | List * | keys1, |
List * | keys2 | ||
) |
Definition at line 304 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(), get_useful_group_keys_orderings(), pathkeys_contained_in(), and set_cheapest().
List* convert_subquery_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | rel, | ||
List * | subquery_pathkeys, | ||
List * | subquery_tlist | ||
) |
Definition at line 1054 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, RelOptInfo::relids, and root.
Referenced by build_setop_child_paths(), set_cte_pathlist(), and set_subquery_pathlist().
List* find_mergeclauses_for_outer_pathkeys | ( | PlannerInfo * | root, |
List * | pathkeys, | ||
List * | restrictinfos | ||
) |
Definition at line 1543 of file pathkeys.c.
References i, j, lappend(), lfirst, list_concat(), NIL, root, and update_mergeclause_eclasses().
Referenced by generate_mergejoin_paths(), and sort_inner_and_outer().
|
static |
Definition at line 1251 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 666 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 699 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 620 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(), generate_union_paths(), and get_cheapest_parameterized_child_path().
List* get_useful_group_keys_orderings | ( | PlannerInfo * | root, |
Path * | path | ||
) |
Definition at line 467 of file pathkeys.c.
References Assert, GroupByOrdering::clauses, compare_pathkeys(), enable_group_by_reordering, enable_incremental_sort, for_each_from, forboth, group_keys_reorder_by_pathkeys(), lappend(), lfirst_node, linitial_node, list_difference(), list_difference_ptr(), list_length(), makeNode, NIL, parse(), GroupByOrdering::pathkeys, Path::pathkeys, pathkeys_contained_in(), PATHKEYS_EQUAL, root, and SortGroupClause::tleSortGroupRef.
Referenced by add_paths_to_grouping_rel(), and create_partial_grouping_paths().
|
static |
Definition at line 370 of file pathkeys.c.
References Assert, foreach_current_index, get_sortgroupref_clause_noerr(), lappend(), lfirst, list_concat_unique_ptr(), list_copy_head(), list_free(), list_length(), list_member_ptr(), NIL, OidIsValid, and SortGroupClause::sortop.
Referenced by get_useful_group_keys_orderings().
bool has_useful_pathkeys | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 2277 of file pathkeys.c.
References RelOptInfo::has_eclass_joins, RelOptInfo::joininfo, NIL, and root.
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 1462 of file pathkeys.c.
References Assert, RestrictInfo::clause, get_eclass_for_sort_expr(), get_leftop(), get_rightop(), NIL, op_input_types(), and root.
Referenced by distribute_qual_to_rels().
PathKey* make_canonical_pathkey | ( | PlannerInfo * | root, |
EquivalenceClass * | eclass, | ||
Oid | opfamily, | ||
int | strategy, | ||
bool | nulls_first | ||
) |
Definition at line 56 of file pathkeys.c.
References eclass(), elog, ERROR, lappend(), lfirst, makeNode, MemoryContextSwitchTo(), PathKey::pk_nulls_first, PathKey::pk_opfamily, PathKey::pk_strategy, and root.
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 1854 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, root, and update_mergeclause_eclasses().
Referenced by generate_mergejoin_paths(), and sort_inner_and_outer().
|
static |
Definition at line 198 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(), OidIsValid, and root.
Referenced by build_expression_pathkey(), build_index_pathkeys(), build_partition_pathkeys(), and make_pathkey_from_sortop().
|
static |
Definition at line 256 of file pathkeys.c.
References elog, ERROR, exprCollation(), get_ordering_op_properties(), make_pathkey_from_sortinfo(), and root.
Referenced by make_pathkeys_for_sortclauses_extended().
List* make_pathkeys_for_sortclauses | ( | PlannerInfo * | root, |
List * | sortclauses, | ||
List * | tlist | ||
) |
Definition at line 1335 of file pathkeys.c.
References Assert, make_pathkeys_for_sortclauses_extended(), and root.
Referenced by adjust_group_pathkeys_for_groupagg(), generate_nonunion_paths(), generate_union_paths(), grouping_planner(), make_pathkeys_for_window(), minmax_qp_callback(), and standard_qp_callback().
List* make_pathkeys_for_sortclauses_extended | ( | PlannerInfo * | root, |
List ** | sortclauses, | ||
List * | tlist, | ||
bool | remove_redundant, | ||
bool | remove_group_rtindex, | ||
bool * | sortable, | ||
bool | set_ec_sortref | ||
) |
Definition at line 1380 of file pathkeys.c.
References Assert, bms_make_singleton(), foreach_delete_current, get_sortgroupclause_expr(), lappend(), lfirst, make_pathkey_from_sortop(), NIL, SortGroupClause::nulls_first, OidIsValid, pathkey_is_redundant(), remove_nulling_relids(), SortGroupClause::reverse_sort, root, SortGroupClause::sortop, and SortGroupClause::tleSortGroupRef.
Referenced by make_pathkeys_for_sortclauses(), make_pathkeys_for_window(), and standard_qp_callback().
|
static |
Definition at line 884 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 844 of file pathkeys.c.
References RelOptInfo::baserestrictinfo, lfirst, matches_boolean_partition_clause(), and PartitionSchemeData::partopfamily.
Referenced by build_partition_pathkeys().
Definition at line 159 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 343 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(), generate_mergejoin_paths(), generate_orderedappend_paths(), get_cheapest_fractional_path_for_pathkeys(), get_cheapest_path_for_pathkeys(), get_useful_group_keys_orderings(), try_mergejoin_path(), and try_partial_mergejoin_path().
Definition at line 558 of file pathkeys.c.
References forboth, lfirst, list_length(), and NIL.
Referenced by build_setop_child_paths(), create_final_distinct_paths(), create_mergejoin_plan(), create_one_window_path(), create_ordered_paths(), create_partial_distinct_paths(), create_window_paths(), gather_grouping_paths(), generate_useful_gather_paths(), initial_cost_mergejoin(), make_ordered_path(), pathkeys_useful_for_ordering(), and pathkeys_useful_for_setop().
|
static |
Definition at line 2186 of file pathkeys.c.
References sort-test::key, lfirst, list_member_ptr(), NIL, and root.
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 2052 of file pathkeys.c.
References eclass_useful_for_merging(), RelOptInfo::has_eclass_joins, i, j, RelOptInfo::joininfo, lfirst, NIL, right_merge_direction(), root, and update_mergeclause_eclasses().
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 2156 of file pathkeys.c.
References pathkeys_count_contained_in(), and root.
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 2216 of file pathkeys.c.
References pathkeys_count_contained_in(), and root.
Referenced by truncate_useless_pathkeys().
|
static |
Definition at line 2119 of file pathkeys.c.
References BTLessStrategyNumber, lfirst, PathKey::pk_opfamily, PathKey::pk_strategy, and root.
Referenced by pathkeys_useful_for_merging().
List* select_outer_pathkeys_for_merge | ( | PlannerInfo * | root, |
List * | mergeclauses, | ||
RelOptInfo * | joinrel | ||
) |
Definition at line 1658 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(), RelOptInfo::relids, root, 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 1957 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 2231 of file pathkeys.c.
References list_copy_head(), list_length(), NIL, pathkeys_useful_for_grouping(), pathkeys_useful_for_merging(), pathkeys_useful_for_ordering(), pathkeys_useful_for_setop(), and root.
Referenced by build_index_paths(), and build_join_pathkeys().
void update_mergeclause_eclasses | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 1509 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().
Definition at line 32 of file pathkeys.c.
Referenced by get_useful_group_keys_orderings().