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 1957 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 2001 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 1635 of file indxpath.c.
References bitmap_scan_cost_est(), and create_bitmap_and_path().
Referenced by choose_bitmap_and().
|
static |
Definition at line 1601 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 704 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 855 of file indxpath.c.
References add_partial_path(), 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, NoMovementScanDirection, 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 1160 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 1805 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 3307 of file indxpath.c.
References PlannerInfo::all_baserels, PlannerInfo::all_result_relids, Assert(), RelOptInfo::baserestrictinfo, 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, 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 1362 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 1664 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 433 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 499 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 235 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, lappend(), RelOptInfo::lateral_relids, lfirst, 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 3440 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 680 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 2856 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, 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, OidIsValid, RowCompareExpr::opfamilies, RowCompareExpr::opnos, pull_varnos(), RowCompareExpr::rargs, RowCompareExpr::rctype, and IndexClause::rinfo.
Referenced by match_rowcompare_to_indexcol().
Definition at line 1732 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 1779 of file indxpath.c.
References equal(), i, lappend(), and lfirst.
Referenced by classify_index_clause_usage().
|
static |
Definition at line 1255 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, RestrictInfo::orclause, and restriction_is_or_clause().
Referenced by create_index_paths().
|
static |
Definition at line 2615 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, T_SupportRequestIndexCondition, and SupportRequestIndexCondition::type.
Referenced by match_funcclause_to_indexcol(), and match_opclause_to_indexcol().
|
static |
Definition at line 733 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 602 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, IndexClauseSet::nonempty, and IndexClause::rinfo.
Referenced by consider_index_join_outer_rels().
|
static |
Definition at line 1904 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 | ( | PlannerInfo * | root, |
IndexOptInfo * | index, | ||
int | indexcol | ||
) |
Definition at line 3669 of file indxpath.c.
References lfirst, match_boolean_index_clause(), and RestrictInfo::pseudoconstant.
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().
|
static |
Definition at line 2363 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 2159 of file indxpath.c.
References IndexClauseSet::indexclauses, lappend(), lfirst, match_clause_to_indexcol(), IndexClauseSet::nonempty, RestrictInfo::pseudoconstant, restriction_is_securely_promotable(), and IndexClause::rinfo.
Referenced by match_clauses_to_index(), and match_join_clauses_to_index().
|
static |
Definition at line 2278 of file indxpath.c.
References 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, and IndexClause::rinfo.
Referenced by match_clause_to_index().
|
static |
Definition at line 3193 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(), OpExpr::opfuncid, and OpExpr::opno.
Referenced by match_pathkeys_to_index().
|
static |
Definition at line 2126 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 2088 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 2569 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 3720 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 2058 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 2450 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, OpExpr::inputcollid, RestrictInfo::left_relids, linitial, list_length(), list_make1, IndexClause::lossy, lsecond, makeNode, match_index_to_operand(), NIL, OidIsValid, op_in_opfamily(), OpExpr::opfuncid, OpExpr::opno, RestrictInfo::right_relids, IndexClause::rinfo, and set_opfuncid().
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 3078 of file indxpath.c.
References 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(), NIL, PathKey::pk_eclass, PathKey::pk_nulls_first, PathKey::pk_opfamily, and PathKey::pk_strategy.
Referenced by build_index_paths().
|
static |
Definition at line 2043 of file indxpath.c.
References match_clauses_to_index().
Referenced by create_index_paths().
|
static |
Definition at line 2749 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, RowCompareExpr::inputcollids, InvalidOid, RowCompareExpr::largs, linitial, linitial_oid, match_index_to_operand(), RowCompareExpr::opnos, pull_varnos(), and RowCompareExpr::rargs.
Referenced by match_clause_to_indexcol().
|
static |
Definition at line 2681 of file indxpath.c.
References ScalarArrayOpExpr::args, bms_is_member(), RestrictInfo::clause, contain_volatile_functions(), if(), IndexClause::indexcol, IndexCollMatchesExprColl, IndexClause::indexcols, IndexClause::indexquals, ScalarArrayOpExpr::inputcollid, 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 1568 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 3498 of file indxpath.c.
References Assert(), RelOptInfo::baserestrictinfo, bms_is_empty(), RestrictInfo::clause, forboth, get_leftop(), get_rightop(), RelOptInfo::indexlist, lappend(), RestrictInfo::left_relids, lfirst, lfirst_oid, list_length(), list_member_oid(), match_index_to_operand(), RestrictInfo::mergeopfamilies, NIL, op_in_opfamily(), RestrictInfo::outer_is_left, and RestrictInfo::right_relids.
Referenced by create_unique_path(), and rel_is_distinct_for().