PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/stratnum.h"
#include "access/sysattr.h"
#include "catalog/pg_am.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_opfamily.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/prep.h"
#include "optimizer/restrictinfo.h"
#include "utils/lsyscache.h"
#include "utils/selfuncs.h"
Go to the source code of this file.
Data Structures | |
struct | IndexClauseSet |
struct | PathClauseUsage |
struct | ec_member_matches_arg |
Macros | |
#define | IndexCollMatchesExprColl(idxcollation, exprcollation) ((idxcollation) == InvalidOid || (idxcollation) == (exprcollation)) |
Enumerations | |
enum | ScanTypeControl { ST_INDEXSCAN, ST_BITMAPSCAN, ST_ANYSCAN } |
#define IndexCollMatchesExprColl | ( | idxcollation, | |
exprcollation | |||
) | ((idxcollation) == InvalidOid || (idxcollation) == (exprcollation)) |
Definition at line 40 of file indxpath.c.
Referenced by ec_member_matches_indexcol(), expand_indexqual_rowcompare(), match_clause_to_ordering_op(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), and match_saopclause_to_indexcol().
enum ScanTypeControl |
Enumerator | |
---|---|
ST_INDEXSCAN | |
ST_BITMAPSCAN | |
ST_ANYSCAN |
Definition at line 44 of file indxpath.c.
|
static |
Definition at line 1966 of file indxpath.c.
References approximate_joinrel_size(), bms_is_member(), estimate_num_groups(), PlannerInfo::join_info_list, JOIN_SEMI, SpecialJoinInfo::jointype, lfirst, SpecialJoinInfo::semi_rhs_exprs, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by get_loop_count().
|
static |
Definition at line 2009 of file indxpath.c.
References Assert, bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, RelOptInfo::rows, PlannerInfo::simple_rel_array, and PlannerInfo::simple_rel_array_size.
Referenced by adjust_rowcount_for_semijoins().
|
static |
Definition at line 1631 of file indxpath.c.
References bitmap_scan_cost_est(), and create_bitmap_and_path().
Referenced by choose_bitmap_and().
|
static |
Definition at line 1597 of file indxpath.c.
References BitmapHeapPath::bitmapqual, cost_bitmap_heap_scan(), get_loop_count(), NIL, Path::parallel_workers, Path::param_info, Path::parent, BitmapHeapPath::path, PATH_REQ_OUTER, Path::pathkeys, Path::pathtarget, Path::pathtype, RelOptInfo::relid, RelOptInfo::reltarget, T_BitmapHeapPath, T_BitmapHeapScan, Path::total_cost, and Path::type.
Referenced by bitmap_and_cost_est(), and choose_bitmap_and().
Definition at line 700 of file indxpath.c.
References bms_equal(), and lfirst.
Referenced by consider_index_join_outer_rels(), create_index_paths(), and get_join_index_paths().
|
static |
Definition at line 851 of file indxpath.c.
References add_partial_path(), IndexOptInfo::amcanorderbyop, IndexOptInfo::amcanparallel, IndexOptInfo::amhasgetbitmap, IndexOptInfo::amhasgettuple, IndexOptInfo::amoptionalkey, IndexOptInfo::amsearcharray, Assert, BackwardScanDirection, bms_add_members(), bms_copy(), bms_del_member(), bms_is_empty(), build_index_pathkeys(), check_index_only(), RestrictInfo::clause, RestrictInfo::clause_relids, RelOptInfo::consider_parallel, create_index_path(), ForwardScanDirection, get_loop_count(), has_useful_pathkeys(), IndexClauseSet::indexclauses, IsA, lappend(), RelOptInfo::lateral_relids, lfirst, match_pathkeys_to_index(), NIL, IndexOptInfo::nkeycolumns, NoMovementScanDirection, Path::parallel_workers, IndexPath::path, pfree(), PlannerInfo::query_pathkeys, RelOptInfo::relid, IndexClause::rinfo, IndexOptInfo::sortopfamily, ST_ANYSCAN, ST_BITMAPSCAN, ST_INDEXSCAN, and truncate_useless_pathkeys().
Referenced by build_paths_for_OR(), and get_index_paths().
|
static |
Definition at line 1156 of file indxpath.c.
References IndexOptInfo::amhasgetbitmap, build_index_paths(), RelOptInfo::indexlist, IndexOptInfo::indpred, lfirst, list_concat(), list_concat_copy(), match_clauses_to_index(), MemSet, NIL, IndexClauseSet::nonempty, predicate_implied_by(), IndexOptInfo::predOK, and ST_BITMAPSCAN.
Referenced by generate_bitmap_or_paths().
|
static |
Definition at line 1801 of file indxpath.c.
References bms_add_member(), bms_del_members(), bms_free(), bms_is_subset(), IndexOptInfo::canreturn, RestrictInfo::clause, enable_indexonlyscan, PathTarget::exprs, FirstLowInvalidHeapAttributeNumber, i, IndexOptInfo::indexkeys, IndexOptInfo::indrestrictinfo, lfirst, IndexOptInfo::ncolumns, pull_varattnos(), RelOptInfo::relid, and RelOptInfo::reltarget.
Referenced by build_index_paths().
void check_index_predicates | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 3308 of file indxpath.c.
References PlannerInfo::all_baserels, Assert, RelOptInfo::baserestrictinfo, bms_difference(), bms_is_empty(), bms_union(), RestrictInfo::clause, contain_mutable_functions(), find_childrel_parents(), generate_join_implied_equalities(), get_plan_rowmark(), RelOptInfo::indexlist, IndexOptInfo::indpred, IndexOptInfo::indrestrictinfo, IS_SIMPLE_REL, join_clause_is_movable_to(), RelOptInfo::joininfo, lappend(), lfirst, list_concat(), list_copy(), list_make1, NIL, PlannerInfo::parse, predicate_implied_by(), IndexOptInfo::predOK, RelOptInfo::relid, RelOptInfo::relids, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, Query::resultRelation, and PlannerInfo::rowMarks.
Referenced by set_plain_rel_size(), and set_tablesample_rel_size().
|
static |
Definition at line 1358 of file indxpath.c.
References Assert, bitmap_and_cost_est(), bitmap_scan_cost_est(), bms_add_members(), bms_copy(), bms_equal(), bms_overlap(), classify_index_clause_usage(), PathClauseUsage::clauseids, cost_bitmap_tree_node(), create_bitmap_and_path(), i, lappend(), lfirst, linitial, list_concat(), list_concat_copy(), list_free(), list_length(), list_make1, list_truncate(), NIL, palloc(), PathClauseUsage::path, path_usage_comparator(), predicate_implied_by(), PathClauseUsage::preds, qsort, PathClauseUsage::quals, and PathClauseUsage::unclassifiable.
Referenced by create_index_paths(), and generate_bitmap_or_paths().
|
static |
Definition at line 1660 of file indxpath.c.
References bms_add_member(), PathClauseUsage::clauseids, find_indexpath_quals(), find_list_position(), lfirst, list_length(), NIL, palloc(), PathClauseUsage::path, PathClauseUsage::preds, PathClauseUsage::quals, and PathClauseUsage::unclassifiable.
Referenced by choose_bitmap_and().
|
static |
Definition at line 429 of file indxpath.c.
References consider_index_join_outer_rels(), IndexClauseSet::indexclauses, list_length(), NIL, and IndexOptInfo::nkeycolumns.
Referenced by create_index_paths().
|
static |
Definition at line 495 of file indxpath.c.
References BMS_DIFFERENT, bms_equal_any(), bms_subset_compare(), bms_union(), RestrictInfo::clause_relids, eclass_already_used(), get_join_index_paths(), lfirst, list_length(), list_nth(), RestrictInfo::parent_ec, and IndexClause::rinfo.
Referenced by consider_index_join_clauses().
void create_index_paths | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 231 of file indxpath.c.
References add_path(), Assert, RelOptInfo::baserestrictinfo, bms_equal_any(), bms_is_subset(), choose_bitmap_and(), consider_index_join_clauses(), RelOptInfo::consider_parallel, create_bitmap_heap_path(), create_partial_bitmap_paths(), generate_bitmap_or_paths(), get_index_paths(), get_loop_count(), INDEX_MAX_KEYS, RelOptInfo::indexlist, IndexOptInfo::indpred, lappend(), RelOptInfo::lateral_relids, lfirst, list_concat(), match_eclass_clauses_to_index(), match_join_clauses_to_index(), match_restriction_clauses_to_index(), MemSet, NIL, IndexOptInfo::nkeycolumns, IndexClauseSet::nonempty, PATH_REQ_OUTER, IndexOptInfo::predOK, and RelOptInfo::relid.
Referenced by set_plain_rel_pathlist().
|
static |
Definition at line 3441 of file indxpath.c.
References Assert, EquivalenceClass::ec_collation, EquivalenceClass::ec_opfamilies, EquivalenceMember::em_expr, IndexOptInfo::indexcollations, IndexCollMatchesExprColl, list_member_oid(), match_index_to_operand(), IndexOptInfo::opfamily, and IndexOptInfo::relam.
Referenced by match_eclass_clauses_to_index().
|
static |
Definition at line 676 of file indxpath.c.
References bms_is_subset(), RestrictInfo::clause_relids, lfirst, RestrictInfo::parent_ec, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 2859 of file indxpath.c.
References bms_is_member(), BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, RestrictInfo::clause, contain_volatile_functions(), copyObject, elog, ERROR, forthree, get_commutator(), get_op_opfamily_properties(), get_op_opfamily_strategy(), get_opfamily_member(), i, IndexClause::indexcol, IndexOptInfo::indexcollations, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, RowCompareExpr::inputcollids, InvalidOid, lappend_int(), lappend_oid(), RowCompareExpr::largs, lfirst_oid, linitial, linitial_oid, list_copy(), list_length(), list_make1, list_make1_int, list_make1_oid, list_nth(), list_nth_oid(), list_truncate(), IndexClause::lossy, make_opclause(), make_simple_restrictinfo, makeNode, match_index_to_operand(), NIL, IndexOptInfo::nkeycolumns, OidIsValid, RowCompareExpr::opfamilies, IndexOptInfo::opfamily, RowCompareExpr::opnos, pull_varnos(), RowCompareExpr::rargs, RowCompareExpr::rctype, IndexOptInfo::rel, RelOptInfo::relid, and IndexClause::rinfo.
Referenced by match_rowcompare_to_indexcol().
Definition at line 1728 of file indxpath.c.
References BitmapAndPath::bitmapquals, BitmapOrPath::bitmapquals, RestrictInfo::clause, elog, ERROR, IndexPath::indexclauses, IndexPath::indexinfo, IndexOptInfo::indpred, IsA, lappend(), lfirst, list_concat(), nodeTag, and IndexClause::rinfo.
Referenced by classify_index_clause_usage().
Definition at line 1775 of file indxpath.c.
References equal(), i, lappend(), and lfirst.
Referenced by classify_index_clause_usage().
|
static |
Definition at line 1251 of file indxpath.c.
References Assert, build_paths_for_OR(), castNode, choose_bitmap_and(), create_bitmap_or_path(), is_andclause(), lappend(), lfirst, lfirst_node, list_concat(), list_concat_copy(), list_make1, NIL, RestrictInfo::orclause, and restriction_is_or_clause().
Referenced by create_index_paths().
|
static |
Definition at line 2622 of file indxpath.c.
References RestrictInfo::clause, DatumGetPointer, SupportRequestIndexCondition::funcid, get_func_support(), SupportRequestIndexCondition::index, SupportRequestIndexCondition::indexarg, SupportRequestIndexCondition::indexcol, IndexClause::indexcol, SupportRequestIndexCondition::indexcollation, IndexOptInfo::indexcollations, IndexClause::indexcols, IndexClause::indexquals, lappend(), lfirst, SupportRequestIndexCondition::lossy, IndexClause::lossy, make_simple_restrictinfo, makeNode, NIL, SupportRequestIndexCondition::node, OidFunctionCall1, OidIsValid, SupportRequestIndexCondition::opfamily, IndexOptInfo::opfamily, PointerGetDatum, IndexClause::rinfo, SupportRequestIndexCondition::root, T_SupportRequestIndexCondition, and SupportRequestIndexCondition::type.
Referenced by match_funcclause_to_indexcol(), and match_opclause_to_indexcol().
|
static |
Definition at line 729 of file indxpath.c.
References add_path(), IndexOptInfo::amhasgetbitmap, IndexOptInfo::amhasgettuple, build_index_paths(), lappend(), lfirst, list_concat(), NIL, Path::pathkeys, IndexOptInfo::predOK, ST_ANYSCAN, and ST_BITMAPSCAN.
Referenced by create_index_paths(), and get_join_index_paths().
|
static |
Definition at line 598 of file indxpath.c.
References Assert, bms_equal_any(), bms_is_subset(), RestrictInfo::clause_relids, get_index_paths(), IndexClauseSet::indexclauses, lappend(), lfirst, list_concat(), MemSet, NIL, IndexOptInfo::nkeycolumns, IndexClauseSet::nonempty, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 1913 of file indxpath.c.
References adjust_rowcount_for_semijoins(), Assert, bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, RelOptInfo::rows, PlannerInfo::simple_rel_array, and PlannerInfo::simple_rel_array_size.
Referenced by bitmap_scan_cost_est(), build_index_paths(), and create_index_paths().
bool indexcol_is_bool_constant_for_query | ( | IndexOptInfo * | index, |
int | indexcol | ||
) |
Definition at line 3670 of file indxpath.c.
References RelOptInfo::baserestrictinfo, lfirst, match_boolean_index_clause(), IndexOptInfo::opfamily, RestrictInfo::pseudoconstant, and IndexOptInfo::rel.
Referenced by build_index_pathkeys().
bool is_pseudo_constant_for_index | ( | Node * | expr, |
IndexOptInfo * | index | ||
) |
Definition at line 3804 of file indxpath.c.
References bms_is_member(), contain_volatile_functions(), pull_varnos(), IndexOptInfo::rel, and RelOptInfo::relid.
|
static |
Definition at line 2371 of file indxpath.c.
References arg, BooleanTest::arg, BooleanTest::booltesttype, RestrictInfo::clause, get_notclausearg(), IndexClause::indexcol, IndexClause::indexcols, IndexClause::indexquals, InvalidOid, IS_FALSE, is_notclause(), IS_TRUE, IsA, list_make1, IndexClause::lossy, make_opclause(), make_simple_restrictinfo, makeBoolConst(), makeNode, match_index_to_operand(), NIL, and IndexClause::rinfo.
Referenced by indexcol_is_bool_constant_for_query(), and match_clause_to_indexcol().
|
static |
Definition at line 2167 of file indxpath.c.
References IndexClauseSet::indexclauses, lappend(), lfirst, match_clause_to_indexcol(), IndexOptInfo::nkeycolumns, IndexClauseSet::nonempty, RestrictInfo::pseudoconstant, IndexOptInfo::rel, restriction_is_securely_promotable(), and IndexClause::rinfo.
Referenced by match_clauses_to_index(), and match_join_clauses_to_index().
|
static |
Definition at line 2286 of file indxpath.c.
References IndexOptInfo::amsearchnulls, NullTest::arg, NullTest::argisrow, Assert, RestrictInfo::clause, IndexClause::indexcol, IndexClause::indexcols, IndexClause::indexquals, IsA, list_make1, IndexClause::lossy, makeNode, match_boolean_index_clause(), match_funcclause_to_indexcol(), match_index_to_operand(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), match_saopclause_to_indexcol(), NIL, IndexOptInfo::opfamily, and IndexClause::rinfo.
Referenced by match_clause_to_index().
|
static |
Definition at line 3194 of file indxpath.c.
References OpExpr::args, Assert, contain_var_clause(), contain_volatile_functions(), get_commutator(), get_leftop(), get_op_opfamily_sortfamily(), get_rightop(), IndexOptInfo::indexcollations, IndexCollMatchesExprColl, InvalidOid, is_opclause(), list_make2, makeNode, match_index_to_operand(), IndexOptInfo::opfamily, OpExpr::opfuncid, and OpExpr::opno.
Referenced by match_pathkeys_to_index().
|
static |
Definition at line 2134 of file indxpath.c.
References lfirst_node, and match_clause_to_index().
Referenced by build_paths_for_OR(), match_eclass_clauses_to_index(), and match_restriction_clauses_to_index().
|
static |
Definition at line 2096 of file indxpath.c.
References arg, ec_member_matches_indexcol(), generate_implied_equalities_for_column(), RelOptInfo::has_eclass_joins, ec_member_matches_arg::index, ec_member_matches_arg::indexcol, RelOptInfo::lateral_referencers, match_clauses_to_index(), IndexOptInfo::nkeycolumns, and IndexOptInfo::rel.
Referenced by create_index_paths().
|
static |
Definition at line 2576 of file indxpath.c.
References FuncExpr::args, RestrictInfo::clause, FuncExpr::funcid, get_index_clause_from_support(), lfirst, and match_index_to_operand().
Referenced by match_clause_to_indexcol().
bool match_index_to_operand | ( | Node * | operand, |
int | indexcol, | ||
IndexOptInfo * | index | ||
) |
Definition at line 3719 of file indxpath.c.
References arg, elog, equal(), ERROR, i, IndexOptInfo::indexkeys, IndexOptInfo::indexprs, IsA, lfirst, list_head(), lnext(), IndexOptInfo::rel, and RelOptInfo::relid.
Referenced by ec_member_matches_indexcol(), expand_indexqual_rowcompare(), get_actual_variable_range(), match_boolean_index_clause(), match_clause_to_indexcol(), match_clause_to_ordering_op(), match_funcclause_to_indexcol(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), match_saopclause_to_indexcol(), and relation_has_unique_index_for().
|
static |
Definition at line 2066 of file indxpath.c.
References join_clause_is_movable_to(), RelOptInfo::joininfo, lappend(), lfirst, match_clause_to_index(), and restriction_is_or_clause().
Referenced by create_index_paths().
|
static |
Definition at line 2457 of file indxpath.c.
References OpExpr::args, bms_is_member(), RestrictInfo::clause, commute_restrictinfo(), contain_volatile_functions(), get_commutator(), get_index_clause_from_support(), IndexClause::indexcol, IndexOptInfo::indexcollations, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, OpExpr::inputcollid, RestrictInfo::left_relids, linitial, list_length(), list_make1, IndexClause::lossy, lsecond, makeNode, match_index_to_operand(), NIL, OidIsValid, op_in_opfamily(), IndexOptInfo::opfamily, OpExpr::opfuncid, OpExpr::opno, IndexOptInfo::rel, RelOptInfo::relid, RestrictInfo::right_relids, IndexClause::rinfo, and set_opfuncid().
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3079 of file indxpath.c.
References IndexOptInfo::amcanorderbyop, bms_equal(), BTLessStrategyNumber, EquivalenceClass::ec_has_volatile, EquivalenceClass::ec_members, EquivalenceMember::em_expr, EquivalenceMember::em_relids, lappend(), lappend_int(), lfirst, match_clause_to_ordering_op(), member, NIL, IndexOptInfo::nkeycolumns, PathKey::pk_eclass, PathKey::pk_nulls_first, PathKey::pk_opfamily, PathKey::pk_strategy, IndexOptInfo::rel, and RelOptInfo::relids.
Referenced by build_index_paths().
|
static |
Definition at line 2051 of file indxpath.c.
References IndexOptInfo::indrestrictinfo, and match_clauses_to_index().
Referenced by create_index_paths().
|
static |
Definition at line 2754 of file indxpath.c.
References bms_is_member(), BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, RestrictInfo::clause, contain_volatile_functions(), expand_indexqual_rowcompare(), get_commutator(), get_op_opfamily_strategy(), IndexOptInfo::indexcollations, IndexCollMatchesExprColl, RowCompareExpr::inputcollids, InvalidOid, RowCompareExpr::largs, linitial, linitial_oid, match_index_to_operand(), IndexOptInfo::opfamily, RowCompareExpr::opnos, pull_varnos(), RowCompareExpr::rargs, IndexOptInfo::rel, IndexOptInfo::relam, and RelOptInfo::relid.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 2687 of file indxpath.c.
References ScalarArrayOpExpr::args, bms_is_member(), RestrictInfo::clause, contain_volatile_functions(), IndexClause::indexcol, IndexOptInfo::indexcollations, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, ScalarArrayOpExpr::inputcollid, linitial, list_make1, IndexClause::lossy, lsecond, makeNode, match_index_to_operand(), NIL, op_in_opfamily(), IndexOptInfo::opfamily, ScalarArrayOpExpr::opno, pull_varnos(), IndexOptInfo::rel, RelOptInfo::relid, IndexClause::rinfo, and ScalarArrayOpExpr::useOr.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 1564 of file indxpath.c.
References cost_bitmap_tree_node(), and PathClauseUsage::path.
Referenced by choose_bitmap_and().
bool relation_has_unique_index_for | ( | PlannerInfo * | root, |
RelOptInfo * | rel, | ||
List * | restrictlist, | ||
List * | exprlist, | ||
List * | oprlist | ||
) |
Definition at line 3499 of file indxpath.c.
References Assert, RelOptInfo::baserestrictinfo, bms_is_empty(), RestrictInfo::clause, forboth, get_leftop(), get_rightop(), IndexOptInfo::immediate, RelOptInfo::indexlist, IndexOptInfo::indpred, lappend(), RestrictInfo::left_relids, lfirst, lfirst_oid, list_length(), list_member_oid(), match_index_to_operand(), RestrictInfo::mergeopfamilies, NIL, IndexOptInfo::nkeycolumns, op_in_opfamily(), IndexOptInfo::opfamily, RestrictInfo::outer_is_left, IndexOptInfo::predOK, RestrictInfo::right_relids, and IndexOptInfo::unique.
Referenced by create_unique_path(), and rel_is_distinct_for().