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_amop.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/array.h"
#include "utils/lsyscache.h"
#include "utils/selfuncs.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | IndexClauseSet |
struct | PathClauseUsage |
struct | ec_member_matches_arg |
struct | OrArgIndexMatch |
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 43 of file indxpath.c.
enum ScanTypeControl |
|
static |
Definition at line 2315 of file indxpath.c.
References approximate_joinrel_size(), bms_is_member(), estimate_num_groups(), JOIN_SEMI, SpecialJoinInfo::jointype, lfirst, root, SpecialJoinInfo::semi_rhs_exprs, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by get_loop_count().
|
static |
Definition at line 2359 of file indxpath.c.
References Assert, bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, root, and RelOptInfo::rows.
Referenced by adjust_rowcount_for_semijoins().
|
static |
Definition at line 1993 of file indxpath.c.
References bitmap_scan_cost_est(), create_bitmap_and_path(), and root.
Referenced by choose_bitmap_and().
|
static |
Definition at line 1959 of file indxpath.c.
References BitmapHeapPath::bitmapqual, cost_bitmap_heap_scan(), get_loop_count(), NIL, Path::parallel_workers, BitmapHeapPath::path, PATH_REQ_OUTER, Path::pathkeys, Path::pathtype, RelOptInfo::relid, RelOptInfo::reltarget, root, and Path::total_cost.
Referenced by bitmap_and_cost_est(), and choose_bitmap_and().
|
static |
Definition at line 811 of file indxpath.c.
References add_partial_path(), Assert, BackwardScanDirection, bms_add_members(), bms_copy(), bms_del_member(), build_index_pathkeys(), check_index_only(), RestrictInfo::clause, RelOptInfo::consider_parallel, create_index_path(), ForwardScanDirection, get_loop_count(), has_useful_pathkeys(), IndexClauseSet::indexclauses, IsA, lappend(), RelOptInfo::lateral_relids, lfirst, list_copy_head(), list_length(), match_pathkeys_to_index(), NIL, Path::parallel_workers, IndexPath::path, pfree(), RelOptInfo::relid, IndexClause::rinfo, root, ST_ANYSCAN, ST_BITMAPSCAN, ST_INDEXSCAN, and truncate_useless_pathkeys().
Referenced by build_paths_for_OR(), and get_index_paths().
|
static |
Definition at line 1093 of file indxpath.c.
References build_index_paths(), RelOptInfo::indexlist, lfirst, list_concat(), list_concat_copy(), match_clauses_to_index(), MemSet, NIL, IndexClauseSet::nonempty, predicate_implied_by(), root, and ST_BITMAPSCAN.
Referenced by generate_bitmap_or_paths(), and make_bitmap_paths_for_or_group().
|
static |
Definition at line 2163 of file indxpath.c.
References bms_add_member(), bms_free(), bms_is_subset(), RestrictInfo::clause, enable_indexonlyscan, PathTarget::exprs, FirstLowInvalidHeapAttributeNumber, i, lfirst, pull_varattnos(), RelOptInfo::relid, and RelOptInfo::reltarget.
Referenced by build_index_paths().
void check_index_predicates | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 3946 of file indxpath.c.
References Assert, RelOptInfo::baserestrictinfo, bms_del_members(), bms_difference(), bms_is_empty, bms_is_member(), bms_union(), RestrictInfo::clause, contain_mutable_functions(), find_childrel_parents(), generate_join_implied_equalities(), get_plan_rowmark(), RelOptInfo::indexlist, IS_SIMPLE_REL, join_clause_is_movable_to(), RelOptInfo::joininfo, lappend(), lfirst, list_concat(), list_copy(), list_make1, NIL, RelOptInfo::nulling_relids, predicate_implied_by(), RelOptInfo::relid, RelOptInfo::relids, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, and root.
Referenced by set_plain_rel_size(), and set_tablesample_rel_size().
|
static |
Definition at line 1720 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, j, 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, root, and PathClauseUsage::unclassifiable.
Referenced by create_index_paths(), generate_bitmap_or_paths(), and make_bitmap_paths_for_or_group().
|
static |
Definition at line 2022 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 438 of file indxpath.c.
References consider_index_join_outer_rels(), IndexClauseSet::indexclauses, list_length(), NIL, and root.
Referenced by create_index_paths().
|
static |
Definition at line 504 of file indxpath.c.
References BMS_DIFFERENT, bms_subset_compare(), bms_union(), eclass_already_used(), get_join_index_paths(), lfirst, list_length(), list_member(), list_nth(), IndexClause::rinfo, and root.
Referenced by consider_index_join_clauses().
void create_index_paths | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 241 of file indxpath.c.
References add_path(), Assert, RelOptInfo::baserestrictinfo, 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, lappend(), RelOptInfo::lateral_relids, lfirst, list_append_unique(), list_concat(), match_eclass_clauses_to_index(), match_join_clauses_to_index(), match_restriction_clauses_to_index(), MemSet, NIL, IndexClauseSet::nonempty, PATH_REQ_OUTER, RelOptInfo::relid, and root.
Referenced by set_plain_rel_pathlist().
|
static |
Definition at line 4084 of file indxpath.c.
References arg, Assert, EquivalenceClass::ec_collation, EquivalenceClass::ec_opfamilies, EquivalenceMember::em_expr, IndexCollMatchesExprColl, list_member_oid(), and match_index_to_operand().
Referenced by match_eclass_clauses_to_index().
|
static |
Definition at line 685 of file indxpath.c.
References bms_is_subset(), lfirst, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 3500 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, if(), IndexClause::indexcol, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, InvalidOid, lappend_int(), lappend_oid(), RowCompareExpr::largs, lfirst_oid, linitial, linitial_oid, list_copy_head(), 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, OidIsValid, pull_varnos(), RowCompareExpr::rargs, RowCompareExpr::rctype, IndexClause::rinfo, and root.
Referenced by match_rowcompare_to_indexcol().
Definition at line 2090 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 2137 of file indxpath.c.
References equal(), i, lappend(), and lfirst.
Referenced by classify_index_clause_usage().
|
static |
Definition at line 1564 of file indxpath.c.
References build_paths_for_OR(), castNode, choose_bitmap_and(), create_bitmap_or_path(), group_similar_or_args(), is_andclause(), j, lappend(), lfirst, lfirst_node, list_concat(), list_concat_copy(), list_copy(), list_delete(), list_free(), list_make1, make_bitmap_paths_for_or_group(), NIL, restriction_is_or_clause(), and root.
Referenced by create_index_paths().
|
static |
Definition at line 3001 of file indxpath.c.
References RestrictInfo::clause, DatumGetPointer(), SupportRequestIndexCondition::funcid, get_func_support(), SupportRequestIndexCondition::index, SupportRequestIndexCondition::indexarg, IndexClause::indexcol, SupportRequestIndexCondition::indexcol, SupportRequestIndexCondition::indexcollation, IndexClause::indexcols, IndexClause::indexquals, lappend(), lfirst, IndexClause::lossy, SupportRequestIndexCondition::lossy, make_simple_restrictinfo, makeNode, NIL, SupportRequestIndexCondition::node, OidFunctionCall1, OidIsValid, SupportRequestIndexCondition::opfamily, PointerGetDatum(), IndexClause::rinfo, root, SupportRequestIndexCondition::root, and SupportRequestIndexCondition::type.
Referenced by match_funcclause_to_indexcol(), and match_opclause_to_indexcol().
|
static |
Definition at line 717 of file indxpath.c.
References add_path(), build_index_paths(), IndexPath::indexselectivity, lappend(), lfirst, list_concat(), NIL, IndexPath::path, Path::pathkeys, root, ST_ANYSCAN, and ST_BITMAPSCAN.
Referenced by create_index_paths(), and get_join_index_paths().
|
static |
Definition at line 607 of file indxpath.c.
References Assert, bms_is_subset(), get_index_paths(), IndexClauseSet::indexclauses, lappend(), lfirst, list_concat(), list_member(), MemSet, NIL, IndexClauseSet::nonempty, IndexClause::rinfo, and root.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 2262 of file indxpath.c.
References adjust_rowcount_for_semijoins(), Assert, bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, root, and RelOptInfo::rows.
Referenced by bitmap_scan_cost_est(), build_index_paths(), and create_index_paths().
|
static |
Definition at line 1247 of file indxpath.c.
References arg, OrArgIndexMatch::argindex, generate_unaccent_rules::args, OpExpr::args, Assert, castNode, RestrictInfo::clause, OrArgIndexMatch::colnum, get_commutator(), get_leftop(), get_rightop(), RestrictInfo::has_clone, i, if(), RestrictInfo::incompatible_relids, RelOptInfo::indexlist, OrArgIndexMatch::indexnum, OrArgIndexMatch::inputcollid, InvalidOid, RestrictInfo::is_clone, RestrictInfo::is_pushed_down, IsA, j, lappend(), lfirst, list_length(), list_nth(), make_orclause(), make_plain_restrictinfo(), match_index_to_operand(), NIL, OidIsValid, OrArgIndexMatch::opno, OpExpr::opno, or_arg_index_match_cmp(), RestrictInfo::outer_relids, palloc(), pfree(), qsort, RestrictInfo::required_relids, root, and RestrictInfo::security_level.
Referenced by generate_bitmap_or_paths().
bool indexcol_is_bool_constant_for_query | ( | PlannerInfo * | root, |
IndexOptInfo * | index, | ||
int | indexcol | ||
) |
Definition at line 4316 of file indxpath.c.
References IsBooleanOpfamily(), lfirst, match_boolean_index_clause(), and root.
Referenced by build_index_pathkeys().
bool is_pseudo_constant_for_index | ( | PlannerInfo * | root, |
Node * | expr, | ||
IndexOptInfo * | index | ||
) |
Definition at line 4453 of file indxpath.c.
References bms_is_member(), contain_volatile_functions(), pull_varnos(), and root.
Definition at line 2724 of file indxpath.c.
References FirstNormalObjectId, and op_in_opfamily().
Referenced by indexcol_is_bool_constant_for_query(), and match_clause_to_indexcol().
|
static |
Definition at line 1483 of file indxpath.c.
References generate_unaccent_rules::args, build_paths_for_OR(), choose_bitmap_and(), lappend(), lfirst, list_make1, NIL, root, and Path::total_cost.
Referenced by generate_bitmap_or_paths().
|
static |
Definition at line 2749 of file indxpath.c.
References arg, BooleanTest::arg, BooleanTest::booltesttype, RestrictInfo::clause, get_notclausearg(), if(), 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, IndexClause::rinfo, and root.
Referenced by indexcol_is_bool_constant_for_query(), and match_clause_to_indexcol().
|
static |
Definition at line 2517 of file indxpath.c.
References IndexClauseSet::indexclauses, lappend(), lfirst, match_clause_to_indexcol(), IndexClauseSet::nonempty, restriction_is_securely_promotable(), IndexClause::rinfo, and root.
Referenced by match_clauses_to_index(), and match_join_clauses_to_index().
|
static |
Definition at line 2643 of file indxpath.c.
References NullTest::arg, Assert, RestrictInfo::clause, IndexClause::indexcol, IndexClause::indexcols, IndexClause::indexquals, IsA, IsBooleanOpfamily(), list_make1, IndexClause::lossy, makeNode, match_boolean_index_clause(), match_funcclause_to_indexcol(), match_index_to_operand(), match_opclause_to_indexcol(), match_orclause_to_indexcol(), match_rowcompare_to_indexcol(), match_saopclause_to_indexcol(), NIL, restriction_is_or_clause(), IndexClause::rinfo, and root.
Referenced by match_clause_to_index().
|
static |
Definition at line 3832 of file indxpath.c.
References OpExpr::args, Assert, contain_var_clause(), contain_volatile_functions(), get_commutator(), get_leftop(), get_op_opfamily_sortfamily(), get_rightop(), IndexCollMatchesExprColl, InvalidOid, is_opclause(), list_make2, makeNode, match_index_to_operand(), and OpExpr::opno.
Referenced by match_pathkeys_to_index().
|
static |
Definition at line 2484 of file indxpath.c.
References lfirst_node, match_clause_to_index(), and root.
Referenced by build_paths_for_OR(), match_eclass_clauses_to_index(), and match_restriction_clauses_to_index().
|
static |
Definition at line 2446 of file indxpath.c.
References arg, ec_member_matches_indexcol(), generate_implied_equalities_for_column(), match_clauses_to_index(), and root.
Referenced by create_index_paths().
|
static |
Definition at line 2955 of file indxpath.c.
References FuncExpr::args, RestrictInfo::clause, FuncExpr::funcid, get_index_clause_from_support(), lfirst, match_index_to_operand(), and root.
Referenced by match_clause_to_indexcol().
bool match_index_to_operand | ( | Node * | operand, |
int | indexcol, | ||
IndexOptInfo * | index | ||
) |
Definition at line 4367 of file indxpath.c.
References arg, elog, equal(), ERROR, i, IsA, lfirst, list_head(), and lnext().
Referenced by ec_member_matches_indexcol(), expand_indexqual_rowcompare(), get_actual_variable_range(), group_similar_or_args(), match_boolean_index_clause(), match_clause_to_indexcol(), match_clause_to_ordering_op(), match_funcclause_to_indexcol(), match_opclause_to_indexcol(), match_orclause_to_indexcol(), match_rowcompare_to_indexcol(), match_saopclause_to_indexcol(), and relation_has_unique_index_for().
|
static |
Definition at line 2416 of file indxpath.c.
References join_clause_is_movable_to(), RelOptInfo::joininfo, lappend(), lfirst, match_clause_to_index(), restriction_is_or_clause(), and root.
Referenced by create_index_paths().
|
static |
Definition at line 2836 of file indxpath.c.
References OpExpr::args, bms_is_member(), RestrictInfo::clause, commute_restrictinfo(), contain_volatile_functions(), get_commutator(), get_index_clause_from_support(), if(), IndexClause::indexcol, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, linitial, list_length(), list_make1, IndexClause::lossy, lsecond, makeNode, match_index_to_operand(), NIL, OidIsValid, op_in_opfamily(), OpExpr::opno, IndexClause::rinfo, root, and set_opfuncid().
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3229 of file indxpath.c.
References arg, OpExpr::args, BoolExpr::args, Assert, bms_equal(), bms_is_subset(), BoolExpr::boolop, RestrictInfo::clause, construct_array(), ArrayExpr::elements, exprType(), foreach_node, get_array_type(), get_commutator(), get_op_rettype(), get_opcode(), get_typlenbyvalalign(), i, if(), RestrictInfo::incompatible_relids, IndexCollMatchesExprColl, InvalidOid, RestrictInfo::is_clone, RestrictInfo::is_pushed_down, IsA, lappend(), lfirst, linitial, list_free(), list_length(), list_make1, list_make2, ArrayExpr::location, lsecond, make_simple_restrictinfo, makeConst(), makeNode, match_index_to_operand(), NIL, OidIsValid, op_in_opfamily(), OpExpr::opno, OR_EXPR, RestrictInfo::outer_relids, palloc(), pfree(), PointerGetDatum(), RestrictInfo::required_relids, root, RestrictInfo::security_level, typalign, type_is_rowtype(), and value.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3722 of file indxpath.c.
References bms_equal(), BTLessStrategyNumber, EquivalenceMember::em_expr, EquivalenceMember::em_relids, lappend(), lappend_int(), lfirst, match_clause_to_ordering_op(), NIL, PathKey::pk_nulls_first, PathKey::pk_opfamily, and PathKey::pk_strategy.
Referenced by build_index_paths().
|
static |
Definition at line 2401 of file indxpath.c.
References match_clauses_to_index(), and root.
Referenced by create_index_paths().
|
static |
Definition at line 3135 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(), if(), IndexCollMatchesExprColl, InvalidOid, RowCompareExpr::largs, linitial, linitial_oid, match_index_to_operand(), pull_varnos(), RowCompareExpr::rargs, and root.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3067 of file indxpath.c.
References ScalarArrayOpExpr::args, bms_is_member(), RestrictInfo::clause, contain_volatile_functions(), if(), IndexClause::indexcol, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, linitial, list_make1, IndexClause::lossy, lsecond, makeNode, match_index_to_operand(), NIL, op_in_opfamily(), ScalarArrayOpExpr::opno, pull_varnos(), IndexClause::rinfo, root, and ScalarArrayOpExpr::useOr.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 1199 of file indxpath.c.
References a, OrArgIndexMatch::argindex, b, OrArgIndexMatch::colnum, OrArgIndexMatch::indexnum, OrArgIndexMatch::inputcollid, and OrArgIndexMatch::opno.
Referenced by group_similar_or_args().
|
static |
Definition at line 1926 of file indxpath.c.
References a, b, 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 4142 of file indxpath.c.
References Assert, RelOptInfo::baserestrictinfo, bms_is_empty, RestrictInfo::clause, forboth, get_leftop(), get_rightop(), RelOptInfo::indexlist, lappend(), lfirst, lfirst_oid, list_length(), list_member_oid(), match_index_to_operand(), NIL, and op_in_opfamily().
Referenced by create_unique_path(), and rel_is_distinct_for().