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.
enum ScanTypeControl |
|
static |
Definition at line 1936 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 1980 of file indxpath.c.
References Assert(), bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, RelOptInfo::rows, and PlannerInfo::simple_rel_array_size.
Referenced by adjust_rowcount_for_semijoins().
|
static |
Definition at line 1614 of file indxpath.c.
References bitmap_scan_cost_est(), and create_bitmap_and_path().
Referenced by choose_bitmap_and().
|
static |
Definition at line 1580 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, and Path::total_cost.
Referenced by bitmap_and_cost_est(), and choose_bitmap_and().
|
static |
Definition at line 835 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(), PlannerInfo::query_pathkeys, RelOptInfo::relid, IndexClause::rinfo, ST_ANYSCAN, ST_BITMAPSCAN, ST_INDEXSCAN, and truncate_useless_pathkeys().
Referenced by build_paths_for_OR(), and get_index_paths().
|
static |
Definition at line 1139 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(), and ST_BITMAPSCAN.
Referenced by generate_bitmap_or_paths().
|
static |
Definition at line 1784 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 3298 of file indxpath.c.
References PlannerInfo::all_query_rels, PlannerInfo::all_result_relids, 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 PlannerInfo::rowMarks.
Referenced by set_plain_rel_size(), and set_tablesample_rel_size().
|
static |
Definition at line 1341 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, and PathClauseUsage::unclassifiable.
Referenced by create_index_paths(), and generate_bitmap_or_paths().
|
static |
Definition at line 1643 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 432 of file indxpath.c.
References consider_index_join_outer_rels(), IndexClauseSet::indexclauses, list_length(), and NIL.
Referenced by create_index_paths().
|
static |
Definition at line 498 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(), and IndexClause::rinfo.
Referenced by consider_index_join_clauses().
void create_index_paths | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 235 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, and RelOptInfo::relid.
Referenced by set_plain_rel_pathlist().
|
static |
Definition at line 3436 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 679 of file indxpath.c.
References bms_is_subset(), lfirst, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 2852 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, and IndexClause::rinfo.
Referenced by match_rowcompare_to_indexcol().
Definition at line 1711 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 1758 of file indxpath.c.
References equal(), i, lappend(), and lfirst.
Referenced by classify_index_clause_usage().
|
static |
Definition at line 1234 of file indxpath.c.
References Assert(), build_paths_for_OR(), castNode, choose_bitmap_and(), create_bitmap_or_path(), is_andclause(), j, lappend(), lfirst, lfirst_node, list_concat(), list_concat_copy(), list_make1, NIL, and restriction_is_or_clause().
Referenced by create_index_paths().
|
static |
Definition at line 2611 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, SupportRequestIndexCondition::root, and SupportRequestIndexCondition::type.
Referenced by match_funcclause_to_indexcol(), and match_opclause_to_indexcol().
|
static |
Definition at line 713 of file indxpath.c.
References add_path(), build_index_paths(), IndexPath::indexselectivity, lappend(), lfirst, list_concat(), NIL, IndexPath::path, Path::pathkeys, ST_ANYSCAN, and ST_BITMAPSCAN.
Referenced by create_index_paths(), and get_join_index_paths().
|
static |
Definition at line 601 of file indxpath.c.
References Assert(), bms_is_subset(), get_index_paths(), IndexClauseSet::indexclauses, lappend(), lfirst, list_concat(), list_member(), MemSet, NIL, IndexClauseSet::nonempty, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 1883 of file indxpath.c.
References adjust_rowcount_for_semijoins(), Assert(), bms_next_member(), IS_DUMMY_REL, RelOptInfo::relid, RelOptInfo::rows, 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 | ( | PlannerInfo * | root, |
IndexOptInfo * | index, | ||
int | indexcol | ||
) |
Definition at line 3668 of file indxpath.c.
References IsBooleanOpfamily(), lfirst, and match_boolean_index_clause().
Referenced by build_index_pathkeys().
bool is_pseudo_constant_for_index | ( | PlannerInfo * | root, |
Node * | expr, | ||
IndexOptInfo * | index | ||
) |
Definition at line 3805 of file indxpath.c.
References bms_is_member(), contain_volatile_functions(), and pull_varnos().
Definition at line 2334 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 2359 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, and IndexClause::rinfo.
Referenced by indexcol_is_bool_constant_for_query(), and match_clause_to_indexcol().
|
static |
Definition at line 2138 of file indxpath.c.
References IndexClauseSet::indexclauses, lappend(), lfirst, match_clause_to_indexcol(), IndexClauseSet::nonempty, restriction_is_securely_promotable(), and IndexClause::rinfo.
Referenced by match_clauses_to_index(), and match_join_clauses_to_index().
|
static |
Definition at line 2257 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_rowcompare_to_indexcol(), match_saopclause_to_indexcol(), NIL, and IndexClause::rinfo.
Referenced by match_clause_to_index().
|
static |
Definition at line 3184 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 2105 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 2067 of file indxpath.c.
References arg, ec_member_matches_indexcol(), generate_implied_equalities_for_column(), and match_clauses_to_index().
Referenced by create_index_paths().
|
static |
Definition at line 2565 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, IsA, lfirst, list_head(), and lnext().
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 2037 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 2446 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, and set_opfuncid().
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3074 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 2022 of file indxpath.c.
References match_clauses_to_index().
Referenced by create_index_paths().
|
static |
Definition at line 2745 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(), and RowCompareExpr::rargs.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 2677 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, and ScalarArrayOpExpr::useOr.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 1547 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 3494 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().