|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <ctype.h>#include <math.h>#include "access/brin.h"#include "access/brin_page.h"#include "access/gin.h"#include "access/table.h"#include "access/tableam.h"#include "access/visibilitymap.h"#include "catalog/pg_collation.h"#include "catalog/pg_operator.h"#include "catalog/pg_statistic.h"#include "catalog/pg_statistic_ext.h"#include "executor/nodeAgg.h"#include "miscadmin.h"#include "nodes/makefuncs.h"#include "nodes/nodeFuncs.h"#include "optimizer/clauses.h"#include "optimizer/cost.h"#include "optimizer/optimizer.h"#include "optimizer/pathnode.h"#include "optimizer/paths.h"#include "optimizer/plancat.h"#include "parser/parse_clause.h"#include "parser/parse_relation.h"#include "parser/parsetree.h"#include "rewrite/rewriteManip.h"#include "statistics/statistics.h"#include "storage/bufmgr.h"#include "utils/acl.h"#include "utils/array.h"#include "utils/builtins.h"#include "utils/date.h"#include "utils/datum.h"#include "utils/fmgroids.h"#include "utils/index_selfuncs.h"#include "utils/lsyscache.h"#include "utils/memutils.h"#include "utils/pg_locale.h"#include "utils/rel.h"#include "utils/selfuncs.h"#include "utils/snapmgr.h"#include "utils/spccache.h"#include "utils/syscache.h"#include "utils/timestamp.h"#include "utils/typcache.h"#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
| struct | MCVHashEntry |
| struct | MCVHashContext |
| struct | GroupVarInfo |
| struct | GinQualCounts |
Macros | |
| #define | DEFAULT_PAGE_CPU_MULTIPLIER 50.0 |
| #define | EQJOINSEL_MCV_HASH_THRESHOLD 200 |
| #define | SH_PREFIX MCVHashTable |
| #define | SH_ELEMENT_TYPE MCVHashEntry |
| #define | SH_KEY_TYPE Datum |
| #define | SH_KEY value |
| #define | SH_HASH_KEY(tab, key) hash_mcv(tab, key) |
| #define | SH_EQUAL(tab, key0, key1) mcvs_equal(tab, key0, key1) |
| #define | SH_SCOPE static inline |
| #define | SH_STORE_HASH |
| #define | SH_GET_HASH(tab, ent) (ent)->hash |
| #define | SH_DEFINE |
| #define | SH_DECLARE |
| #define | VISITED_PAGES_LIMIT 100 |
Typedefs | |
| typedef struct MCVHashEntry | MCVHashEntry |
| typedef struct MCVHashContext | MCVHashContext |
| typedef struct MCVHashTable_hash | MCVHashTable_hash |
Variables | |
| get_relation_stats_hook_type | get_relation_stats_hook = NULL |
| get_index_stats_hook_type | get_index_stats_hook = NULL |
| #define DEFAULT_PAGE_CPU_MULTIPLIER 50.0 |
Definition at line 144 of file selfuncs.c.
| #define EQJOINSEL_MCV_HASH_THRESHOLD 200 |
Definition at line 154 of file selfuncs.c.
| #define SH_DECLARE |
Definition at line 289 of file selfuncs.c.
| #define SH_DEFINE |
Definition at line 288 of file selfuncs.c.
| #define SH_ELEMENT_TYPE MCVHashEntry |
Definition at line 280 of file selfuncs.c.
Definition at line 284 of file selfuncs.c.
Definition at line 283 of file selfuncs.c.
Definition at line 282 of file selfuncs.c.
Definition at line 281 of file selfuncs.c.
| #define SH_PREFIX MCVHashTable |
Definition at line 279 of file selfuncs.c.
Definition at line 285 of file selfuncs.c.
| #define SH_STORE_HASH |
Definition at line 286 of file selfuncs.c.
| #define VISITED_PAGES_LIMIT 100 |
| typedef struct MCVHashContext MCVHashContext |
| typedef struct MCVHashEntry MCVHashEntry |
Definition at line 180 of file selfuncs.c.
| List * add_predicate_to_index_quals | ( | IndexOptInfo * | index, |
| List * | indexQuals | ||
| ) |
Definition at line 7737 of file selfuncs.c.
References fb(), lfirst, list_concat(), list_make1, NIL, and predicate_implied_by().
Referenced by btcostestimate(), genericcostestimate(), and gincostestimate().
|
static |
Definition at line 3674 of file selfuncs.c.
References equal(), exprs_known_equal(), fb(), foreach_delete_current, get_variable_numdistinct(), InvalidOid, lappend(), lfirst, palloc_object, remove_nulling_relids(), and root.
Referenced by estimate_num_groups().
|
static |
Definition at line 6341 of file selfuncs.c.
References clamp_row_est(), fb(), find_base_rel(), GETSTRUCT(), heap_copytuple(), heap_freetuple(), HeapTupleIsValid, STATISTIC_NUM_SLOTS, and Var::varno.
Referenced by examine_simple_variable().
| bool all_rows_selectable | ( | PlannerInfo * | root, |
| Index | varno, | ||
| Bitmapset * | varattnos | ||
| ) |
Definition at line 6415 of file selfuncs.c.
References ACL_SELECT, ACLCHECK_OK, ACLMASK_ALL, Assert, bms_add_member(), bms_next_member(), fb(), find_base_rel_noerr(), FirstLowInvalidHeapAttributeNumber, getRTEPermissionInfo(), GetUserId(), InvalidAttrNumber, NIL, OidIsValid, pg_attribute_aclcheck(), pg_attribute_aclcheck_all(), pg_class_aclcheck(), planner_rt_fetch, root, RTE_RELATION, and RelOptInfo::userid.
Referenced by examine_simple_variable(), examine_variable(), and statext_is_compatible_clause().
| Selectivity booltestsel | ( | PlannerInfo * | root, |
| BoolTestType | booltesttype, | ||
| Node * | arg, | ||
| int | varRelid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 1626 of file selfuncs.c.
References arg, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, clause_selectivity(), DatumGetBool(), DEFAULT_NOT_UNK_SEL, DEFAULT_UNK_SEL, elog, ERROR, examine_variable(), fb(), free_attstatsslot(), get_attstatsslot(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, IS_FALSE, IS_NOT_FALSE, IS_NOT_TRUE, IS_NOT_UNKNOWN, IS_TRUE, IS_UNKNOWN, AttStatsSlot::numbers, ReleaseVariableStats, and root.
Referenced by clause_selectivity_ext().
| Selectivity boolvarsel | ( | PlannerInfo * | root, |
| Node * | arg, | ||
| int | varRelid | ||
| ) |
Definition at line 1587 of file selfuncs.c.
References arg, BoolGetDatum(), examine_variable(), fb(), HeapTupleIsValid, InvalidOid, is_funcclause(), ReleaseVariableStats, root, and var_eq_const().
Referenced by clause_selectivity_ext().
| void brincostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 9127 of file selfuncs.c.
References Assert, attnum, ATTSTATSSLOT_NUMBERS, BoolGetDatum(), BRIN_DEFAULT_PAGES_PER_RANGE, brinGetStats(), CLAMP_PROBABILITY, clauselist_selectivity(), cpu_operator_cost, elog, ERROR, fb(), free_attstatsslot(), get_attstatsslot(), get_index_stats_hook, get_quals_from_indexclauses(), get_relation_stats_hook, get_tablespace_page_costs(), HeapTupleIsValid, index_close(), index_open(), index_other_operands_eval_cost(), IndexPath::indexclauses, IndexPath::indexinfo, Int16GetDatum(), InvalidOid, JOIN_INNER, lfirst_node, Max, Min, NoLock, ObjectIdGetDatum(), planner_rt_fetch, ReleaseSysCache(), ReleaseVariableStats, REVMAP_PAGE_MAXITEMS, root, RTE_RELATION, and SearchSysCache3().
Referenced by brinhandler().
|
static |
Definition at line 7768 of file selfuncs.c.
References Assert, ATTSTATSSLOT_NUMBERS, BTLessStrategyNumber, fb(), free_attstatsslot(), get_attstatsslot(), get_opfamily_member(), HeapTupleIsValid, and OidIsValid.
Referenced by btcostestimate().
| void btcostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 7805 of file selfuncs.c.
References add_predicate_to_index_quals(), ScalarArrayOpExpr::args, Assert, btcost_correlation(), BTEqualStrategyNumber, RestrictInfo::clause, clauselist_selectivity(), cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, DEFAULT_RANGE_INEQ_SEL, elog, ERROR, estimate_array_length(), examine_indexcol_variable(), fb(), genericcostestimate(), get_op_opfamily_strategy(), get_variable_numdistinct(), HeapTupleIsValid, IndexPath::indexclauses, GenericCosts::indexCorrelation, IndexPath::indexinfo, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, InvalidOid, IS_NULL, IsA, JOIN_INNER, lappend(), lfirst_node, linitial_oid, lsecond, Max, Min, NIL, nodeTag, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, GenericCosts::numIndexTuples, GenericCosts::numNonLeafPages, OidIsValid, OpExpr::opno, ScalarArrayOpExpr::opno, ReleaseVariableStats, and root.
Referenced by bthandler().
Definition at line 6007 of file selfuncs.c.
References contain_placeholder_walker(), expression_tree_walker, fb(), and IsA.
Referenced by contain_placeholder_walker(), and strip_all_phvs_deep().
|
static |
Definition at line 5365 of file selfuncs.c.
References convert_one_bytea_to_scalar(), DatumGetByteaPP, fb(), i, Min, value, VARDATA_ANY(), and VARSIZE_ANY_EXHDR().
Referenced by convert_to_scalar().
Definition at line 5075 of file selfuncs.c.
References DatumGetBool(), DatumGetFloat4(), DatumGetFloat8(), DatumGetInt16(), DatumGetInt32(), DatumGetInt64(), DatumGetObjectId(), DirectFunctionCall1, fb(), numeric_float8_no_overflow(), and value.
Referenced by convert_to_scalar().
|
static |
Definition at line 5413 of file selfuncs.c.
Referenced by convert_bytea_to_scalar().
Definition at line 5218 of file selfuncs.c.
Referenced by convert_string_to_scalar().
Definition at line 5269 of file selfuncs.c.
References Assert, collid, DatumGetChar(), DatumGetPointer(), fb(), NameStr, OidIsValid, palloc(), pfree(), pg_newlocale_from_collation(), pg_strxfrm(), PG_USED_FOR_ASSERTS_ONLY, pstrdup(), TextDatumGetCString, val, and value.
Referenced by convert_to_scalar().
|
static |
Definition at line 5138 of file selfuncs.c.
References convert_one_string_to_scalar(), fb(), and value.
Referenced by convert_to_scalar().
Definition at line 5456 of file selfuncs.c.
References date2timestamp_no_overflow(), DatumGetDateADT(), DatumGetIntervalP(), DatumGetTimeADT(), DatumGetTimestamp(), DatumGetTimestampTz(), DatumGetTimeTzADTP(), DAYS_PER_YEAR, fb(), interval::month, MONTHS_PER_YEAR, interval::time, USECS_PER_DAY, and value.
Referenced by convert_to_scalar().
|
static |
Definition at line 4927 of file selfuncs.c.
References collid, convert_bytea_to_scalar(), convert_network_to_scalar(), convert_numeric_to_scalar(), convert_string_datum(), convert_string_to_scalar(), convert_timevalue_to_scalar(), fb(), pfree(), and value.
Referenced by ineq_histogram_selectivity().
| Datum eqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2387 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, elog, eqjoinsel_inner(), EQJOINSEL_MCV_HASH_THRESHOLD, eqjoinsel_semi(), ERROR, exprType(), fb(), find_join_input_rel(), fmgr_info(), free_attstatsslot(), get_attstatsslot(), get_join_variables(), get_op_hash_functions_ext(), get_opcode(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, JOIN_ANTI, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, SpecialJoinInfo::jointype, linitial, Min, SpecialJoinInfo::min_righthand, palloc0(), pfree(), PG_GET_COLLATION, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, ReleaseVariableStats, root, and statistic_proc_security_check().
Referenced by neqjoinsel().
|
static |
Definition at line 2942 of file selfuncs.c.
References CurrentMemoryContext, DatumGetBool(), fb(), fmgr_info(), FunctionCallInvoke, get_typlenbyval(), i, MCVHashEntry::index, InitFunctionCallInfoData, j, likely, LOCAL_FCINFO, and OidIsValid.
Referenced by eqjoinsel_inner(), and eqjoinsel_semi().
|
static |
Definition at line 2592 of file selfuncs.c.
References CLAMP_PROBABILITY, eqjoinsel_find_matches(), fb(), and i.
Referenced by eqjoinsel().
|
static |
Definition at line 2751 of file selfuncs.c.
References CLAMP_PROBABILITY, eqjoinsel_find_matches(), fb(), i, and Min.
Referenced by eqjoinsel().
| Datum eqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 302 of file selfuncs.c.
References eqsel_internal(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 311 of file selfuncs.c.
References DEFAULT_EQ_SEL, fb(), get_negator(), get_restriction_variable(), IsA, OidIsValid, PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, ReleaseVariableStats, root, var_eq_const(), and var_eq_non_const().
| double estimate_array_length | ( | PlannerInfo * | root, |
| Node * | arrayexpr | ||
| ) |
Definition at line 2242 of file selfuncs.c.
References ARR_DIMS, ARR_NDIM, ArrayGetNItems(), ATTSTATSSLOT_NUMBERS, clamp_row_est(), DatumGetArrayTypeP, examine_variable(), fb(), free_attstatsslot(), get_attstatsslot(), HeapTupleIsValid, InvalidOid, IsA, list_length(), ReleaseVariableStats, root, and strip_array_coercion().
Referenced by array_unnest_support(), btcostestimate(), cost_qual_eval_walker(), cost_tidscan(), genericcostestimate(), and gincost_scalararrayopexpr().
| void estimate_hash_bucket_stats | ( | PlannerInfo * | root, |
| Node * | hashkey, | ||
| double | nbuckets, | ||
| Selectivity * | mcv_freq, | ||
| Selectivity * | bucketsize_frac | ||
| ) |
Definition at line 4424 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, clamp_row_est(), examine_variable(), fb(), free_attstatsslot(), get_attstatsslot(), get_variable_numdistinct(), HeapTupleIsValid, InvalidOid, Max, ReleaseVariableStats, and root.
Referenced by final_cost_hashjoin().
| double estimate_hashagg_tablesize | ( | PlannerInfo * | root, |
| Path * | path, | ||
| const AggClauseCosts * | agg_costs, | ||
| double | dNumGroups | ||
| ) |
Definition at line 4530 of file selfuncs.c.
References fb(), hash_agg_entry_size(), list_length(), and root.
Referenced by consider_groupingsets_paths().
| List * estimate_multivariate_bucketsize | ( | PlannerInfo * | root, |
| RelOptInfo * | inner, | ||
| List * | hashclauses, | ||
| Selectivity * | innerbucketsize | ||
| ) |
Definition at line 4156 of file selfuncs.c.
References Assert, bms_get_singleton_member(), RestrictInfo::clause, equal(), estimate_multivariate_ndistinct(), fb(), forboth, foreach_delete_current, get_leftop(), get_rightop(), lappend(), lfirst, lfirst_node, list_concat(), list_copy(), list_free(), list_free_deep(), list_length(), list_member_ptr(), NIL, palloc0_object, remove_nulling_relids(), and root.
Referenced by final_cost_hashjoin().
|
static |
Definition at line 4571 of file selfuncs.c.
References Assert, attnum, MVNDistinctItem::attributes, AttrNumberIsForUserDefinedAttr, bms_add_member(), bms_is_member(), bms_num_members(), elog, equal(), ERROR, StatisticExtInfo::exprs, fb(), i, idx(), StatisticExtInfo::inherit, InvalidOid, IsA, MVNDistinct::items, j, StatisticExtInfo::keys, StatisticExtInfo::kind, lappend(), lfirst, list_length(), MVNDistinctItem::ndistinct, NIL, MVNDistinct::nitems, planner_rt_fetch, RelOptInfo::relid, root, statext_ndistinct_load(), RelOptInfo::statlist, and StatisticExtInfo::statOid.
Referenced by estimate_multivariate_bucketsize(), and estimate_num_groups().
| double estimate_num_groups | ( | PlannerInfo * | root, |
| List * | groupExprs, | ||
| double | input_rows, | ||
| List ** | pgset, | ||
| EstimationInfo * | estinfo | ||
| ) |
Definition at line 3804 of file selfuncs.c.
References add_unique_group_var(), Assert, clamp_row_est(), contain_volatile_functions(), estimate_multivariate_ndistinct(), examine_variable(), expression_returns_set_rows(), exprType(), fb(), for_each_from, HeapTupleIsValid, i, IS_SIMPLE_REL, lappend(), lfirst, linitial, list_member_int(), GroupVarInfo::ndistinct, NIL, pull_var_clause(), PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, ReleaseVariableStats, root, RelOptInfo::rows, SELFLAG_USED_DEFAULT, and RelOptInfo::tuples.
Referenced by adjust_rowcount_for_semijoins(), build_setop_child_paths(), cost_incremental_sort(), cost_memoize_rescan(), create_final_distinct_paths(), create_final_unique_paths(), create_partial_distinct_paths(), create_partial_unique_paths(), create_rel_agg_info(), estimate_path_cost_size(), generate_grouped_paths(), get_number_of_groups(), and get_windowclause_startup_tuples().
|
static |
Definition at line 6610 of file selfuncs.c.
References Assert, BoolGetDatum(), elog, ERROR, fb(), get_index_stats_hook, get_relation_stats_hook, HeapTupleIsValid, Int16GetDatum(), InvalidOid, ObjectIdGetDatum(), planner_rt_fetch, ReleaseSysCache(), root, RTE_RELATION, and SearchSysCache3().
Referenced by btcostestimate().
|
static |
Definition at line 6047 of file selfuncs.c.
References adjust_statstuple_for_grouping(), all_rows_selectable(), Assert, bms_make_singleton(), BoolGetDatum(), CommonTableExpr::ctename, Query::distinctClause, elog, ERROR, examine_simple_variable(), fb(), find_base_rel(), FirstLowInvalidHeapAttributeNumber, get_relation_stats_hook, get_tle_by_resno(), Query::groupClause, Query::groupingSets, HeapTupleIsValid, Int16GetDatum(), InvalidAttrNumber, InvalidOid, IsA, lfirst, list_length(), list_nth(), list_nth_int(), ObjectIdGetDatum(), PlannerInfo::parse, ReleaseSysCache(), Query::returningList, root, RTE_CTE, RTE_RELATION, RTE_SUBQUERY, SearchSysCache3(), Query::setOperations, RelOptInfo::subroot, targetIsInSortList(), Query::targetList, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by examine_simple_variable(), and examine_variable().
| void examine_variable | ( | PlannerInfo * | root, |
| Node * | node, | ||
| int | varRelid, | ||
| VariableStatData * | vardata | ||
| ) |
Definition at line 5651 of file selfuncs.c.
References all_rows_selectable(), arg, Assert, bms_difference(), bms_free(), bms_get_singleton_member(), bms_is_empty, bms_is_member(), bms_overlap(), BoolGetDatum(), elog, equal(), ERROR, examine_simple_variable(), StatisticExtInfo::exprs, exprType(), exprTypmod(), fb(), find_base_rel(), find_join_rel(), get_index_stats_hook, has_unique_index(), HeapTupleIsValid, StatisticExtInfo::inherit, Int16GetDatum(), IsA, StatisticExtInfo::kind, lfirst, list_head(), lnext(), MemSet, NIL, ObjectIdGetDatum(), planner_rt_fetch, pull_varnos(), ReleaseDummy(), ReleaseSysCache(), remove_nulling_relids(), root, SearchSysCache3(), statext_expressions_load(), StatisticExtInfo::statOid, strip_all_phvs_deep(), Var::varattno, and Var::varno.
Referenced by booltestsel(), boolvarsel(), estimate_array_length(), estimate_hash_bucket_stats(), estimate_num_groups(), get_join_variables(), get_restriction_variable(), mergejoinscansel(), nulltestsel(), and scalararraysel_containment().
|
static |
Definition at line 7391 of file selfuncs.c.
References bms_get_singleton_member(), bms_is_empty, elog, ERROR, fb(), find_base_rel(), find_join_rel(), and root.
Referenced by eqjoinsel().
| double generic_restriction_selectivity | ( | PlannerInfo * | root, |
| Oid | oproid, | ||
| Oid | collation, | ||
| List * | args, | ||
| int | varRelid, | ||
| double | default_selectivity | ||
| ) |
Definition at line 989 of file selfuncs.c.
References CLAMP_PROBABILITY, fb(), fmgr_info(), get_opcode(), get_restriction_variable(), GETSTRUCT(), HeapTupleIsValid, histogram_selectivity(), IsA, mcv_selectivity(), ReleaseVariableStats, and root.
Referenced by ltreeparentsel(), and matchingsel().
| void genericcostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| GenericCosts * | costs | ||
| ) |
Definition at line 7512 of file selfuncs.c.
References add_predicate_to_index_quals(), ScalarArrayOpExpr::args, RestrictInfo::clause, clauselist_selectivity(), cpu_index_tuple_cost, cpu_operator_cost, estimate_array_length(), fb(), get_quals_from_indexclauses(), get_tablespace_page_costs(), index_other_operands_eval_cost(), index_pages_fetched(), IndexPath::indexclauses, GenericCosts::indexCorrelation, IndexPath::indexinfo, IndexPath::indexorderbys, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, IsA, JOIN_INNER, lfirst, list_length(), lsecond, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, GenericCosts::numIndexTuples, GenericCosts::numNonLeafPages, root, and GenericCosts::spc_random_page_cost.
Referenced by blcostestimate(), btcostestimate(), gistcostestimate(), hashcostestimate(), and spgcostestimate().
|
static |
Definition at line 7225 of file selfuncs.c.
References datumCopy(), elog, ERROR, ExecClearTuple(), fb(), GlobalVisTestFor(), index_beginscan(), index_deform_tuple(), index_endscan(), index_fetch_heap(), index_getnext_tid(), INDEX_MAX_KEYS, index_rescan(), InitNonVacuumableSnapshot, InvalidBlockNumber, InvalidBuffer, ItemPointerGetBlockNumber(), MemoryContextSwitchTo(), RelationGetRelationName, ReleaseBuffer(), SO_NONE, values, VISITED_PAGES_LIMIT, and VM_ALL_VISIBLE.
Referenced by get_actual_variable_range().
|
static |
Definition at line 7036 of file selfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, BackwardScanDirection, COMPARE_GT, COMPARE_LT, CurrentMemoryContext, ExecDropSingleTupleTableSlot(), fb(), ForwardScanDirection, get_actual_variable_endpoint(), get_op_opfamily_strategy(), get_typlenbyval(), index_close(), index_open(), IndexAmTranslateStrategy(), RelOptInfo::indexlist, InvalidOid, InvalidStrategy, lfirst, match_index_to_operand(), max, MemoryContextDelete(), MemoryContextSwitchTo(), min, NIL, NoLock, RelOptInfo::relid, root, RTE_RELATION, ScanKeyEntryInitialize(), SK_ISNULL, SK_SEARCHNOTNULL, table_close(), table_open(), and table_slot_create().
Referenced by get_variable_range(), and ineq_histogram_selectivity().
| void get_join_variables | ( | PlannerInfo * | root, |
| List * | args, | ||
| SpecialJoinInfo * | sjinfo, | ||
| VariableStatData * | vardata1, | ||
| VariableStatData * | vardata2, | ||
| bool * | join_is_reversed | ||
| ) |
Definition at line 5582 of file selfuncs.c.
References bms_is_subset(), elog, ERROR, examine_variable(), fb(), linitial, list_length(), lsecond, root, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by eqjoinsel(), neqjoinsel(), and networkjoinsel().
Definition at line 7423 of file selfuncs.c.
References fb(), lappend(), lfirst_node, NIL, and result.
Referenced by brincostestimate(), genericcostestimate(), and gincostestimate().
| bool get_restriction_variable | ( | PlannerInfo * | root, |
| List * | args, | ||
| int | varRelid, | ||
| VariableStatData * | vardata, | ||
| Node ** | other, | ||
| bool * | varonleft | ||
| ) |
Definition at line 5522 of file selfuncs.c.
References estimate_expression_value(), examine_variable(), fb(), linitial, list_length(), lsecond, ReleaseVariableStats, and root.
Referenced by _int_matchsel(), arraycontsel(), eqsel_internal(), generic_restriction_selectivity(), multirangesel(), networksel(), patternsel_common(), rangesel(), scalarineqsel_wrapper(), and tsmatchsel().
|
static |
Definition at line 6973 of file selfuncs.c.
References datumCopy(), DatumGetBool(), fb(), fmgr_info(), FunctionCall2Coll(), i, max, and min.
Referenced by get_variable_range().
| double get_variable_numdistinct | ( | VariableStatData * | vardata, |
| bool * | isdefault | ||
| ) |
Definition at line 6713 of file selfuncs.c.
References clamp_row_est(), DEFAULT_NUM_DISTINCT, fb(), GETSTRUCT(), HeapTupleIsValid, IsA, RTE_VALUES, SelfItemPointerAttributeNumber, and TableOidAttributeNumber.
Referenced by add_unique_group_var(), btcostestimate(), eqjoinsel(), estimate_hash_bucket_stats(), ineq_histogram_selectivity(), var_eq_const(), and var_eq_non_const().
|
static |
Definition at line 6846 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, datumCopy(), fb(), free_attstatsslot(), get_actual_variable_range(), get_attstatsslot(), get_opcode(), get_stats_slot_range(), get_typlenbyval(), GETSTRUCT(), HeapTupleIsValid, i, InvalidOid, max, min, root, and statistic_proc_security_check().
Referenced by mergejoinscansel().
|
static |
Definition at line 8571 of file selfuncs.c.
References arg, OpExpr::args, estimate_expression_value(), GinQualCounts::exactEntries, fb(), gincost_pattern(), IsA, lsecond, OpExpr::opno, root, and GinQualCounts::searchEntries.
Referenced by gincostestimate().
|
static |
Definition at line 8457 of file selfuncs.c.
References Assert, GinQualCounts::attHasFullScan, GinQualCounts::attHasNormalScan, elog, ERROR, GinQualCounts::exactEntries, fb(), fmgr_info(), FunctionCall7Coll(), get_op_opfamily_properties(), get_opfamily_proc(), get_rel_name(), GIN_EXTRACTQUERY_PROC, GIN_SEARCH_MODE_DEFAULT, GIN_SEARCH_MODE_INCLUDE_EMPTY, i, OidIsValid, GinQualCounts::partialEntries, PointerGetDatum, GinQualCounts::searchEntries, set_fn_opclass_options(), and UInt16GetDatum().
Referenced by gincost_opexpr(), and gincost_scalararrayopexpr().
|
static |
Definition at line 8621 of file selfuncs.c.
References arg, ScalarArrayOpExpr::args, ARR_ELEMTYPE, GinQualCounts::arrayScans, Assert, DatumGetArrayTypeP, deconstruct_array(), estimate_array_length(), estimate_expression_value(), GinQualCounts::exactEntries, fb(), get_typlenbyvalalign(), gincost_pattern(), i, IsA, lsecond, ScalarArrayOpExpr::opno, GinQualCounts::partialEntries, root, GinQualCounts::searchEntries, and ScalarArrayOpExpr::useOr.
Referenced by gincostestimate().
| void gincostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 8737 of file selfuncs.c.
References add_predicate_to_index_quals(), GinQualCounts::arrayScans, GinQualCounts::attHasFullScan, GinQualCounts::attHasNormalScan, RestrictInfo::clause, clauselist_selectivity(), cpu_index_tuple_cost, cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, elog, ERROR, GinQualCounts::exactEntries, fb(), get_quals_from_indexclauses(), get_tablespace_page_costs(), gincost_opexpr(), gincost_scalararrayopexpr(), ginGetStats(), i, index_close(), index_open(), index_other_operands_eval_cost(), index_pages_fetched(), IndexPath::indexclauses, IndexPath::indexinfo, IsA, JOIN_INNER, lfirst_node, list_length(), Max, Min, NIL, nodeTag, NoLock, GinQualCounts::partialEntries, root, scale, and GinQualCounts::searchEntries.
Referenced by ginhandler().
| void gistcostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 8322 of file selfuncs.c.
References cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, fb(), genericcostestimate(), GenericCosts::indexCorrelation, IndexPath::indexinfo, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, and root.
Referenced by gisthandler().
|
static |
Definition at line 3124 of file selfuncs.c.
References FunctionCallInfoBaseData::args, Assert, DatumGetUInt32(), fb(), FunctionCallInvoke, MCVHashContext::hash_fcinfo, FunctionCallInfoBaseData::isnull, and NullableDatum::value.
| void hashcostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 8277 of file selfuncs.c.
References fb(), genericcostestimate(), GenericCosts::indexCorrelation, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::numIndexPages, GenericCosts::numNonLeafPages, and root.
Referenced by hashhandler().
| double histogram_selectivity | ( | VariableStatData * | vardata, |
| FmgrInfo * | opproc, | ||
| Oid | collation, | ||
| Datum | constval, | ||
| bool | varonleft, | ||
| int | min_hist_size, | ||
| int | n_skip, | ||
| int * | hist_size | ||
| ) |
Definition at line 898 of file selfuncs.c.
References Assert, ATTSTATSSLOT_VALUES, DatumGetBool(), fb(), free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, result, and statistic_proc_security_check().
Referenced by generic_restriction_selectivity(), and patternsel_common().
| Cost index_other_operands_eval_cost | ( | PlannerInfo * | root, |
| List * | indexquals | ||
| ) |
Definition at line 7453 of file selfuncs.c.
References OpExpr::args, ScalarArrayOpExpr::args, cost_qual_eval_node(), elog, ERROR, fb(), IsA, lfirst, lsecond, nodeTag, RowCompareExpr::rargs, and root.
Referenced by brincostestimate(), genericcostestimate(), and gincostestimate().
| double ineq_histogram_selectivity | ( | PlannerInfo * | root, |
| VariableStatData * | vardata, | ||
| Oid | opoid, | ||
| FmgrInfo * | opproc, | ||
| bool | isgt, | ||
| bool | iseq, | ||
| Oid | collation, | ||
| Datum | constval, | ||
| Oid | consttype | ||
| ) |
Definition at line 1116 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, comparison_ops_are_compatible(), convert_to_scalar(), DatumGetBool(), fb(), free_attstatsslot(), FunctionCall2Coll(), FunctionCallInvoke, get_actual_variable_range(), get_attstatsslot(), get_variable_numdistinct(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, AttStatsSlot::nvalues, root, statistic_proc_security_check(), and val.
Referenced by prefix_selectivity(), and scalarineqsel().
| Datum matchingjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3653 of file selfuncs.c.
References DEFAULT_MATCHING_SEL, and PG_RETURN_FLOAT8.
| Datum matchingsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3635 of file selfuncs.c.
References DEFAULT_MATCHING_SEL, fb(), generic_restriction_selectivity(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, and root.
| double mcv_selectivity | ( | VariableStatData * | vardata, |
| FmgrInfo * | opproc, | ||
| Oid | collation, | ||
| Datum | constval, | ||
| bool | varonleft, | ||
| double * | sumcommonp | ||
| ) |
Definition at line 807 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetBool(), fb(), free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, and statistic_proc_security_check().
Referenced by generic_restriction_selectivity(), networksel(), patternsel_common(), and scalarineqsel().
|
static |
Definition at line 3138 of file selfuncs.c.
References FunctionCallInfoBaseData::args, datum_image_eq(), DatumGetBool(), MCVHashContext::equal_fcinfo, fb(), FunctionCallInvoke, MCVHashContext::hash_typbyval, MCVHashContext::hash_typlen, MCVHashContext::insert_mode, FunctionCallInfoBaseData::isnull, MCVHashContext::op_is_reversed, and NullableDatum::value.
| void mergejoinscansel | ( | PlannerInfo * | root, |
| Node * | clause, | ||
| Oid | opfamily, | ||
| CompareType | cmptype, | ||
| bool | nulls_first, | ||
| Selectivity * | leftstart, | ||
| Selectivity * | leftend, | ||
| Selectivity * | rightstart, | ||
| Selectivity * | rightend | ||
| ) |
Definition at line 3318 of file selfuncs.c.
References Assert, CLAMP_PROBABILITY, COMPARE_EQ, COMPARE_GE, COMPARE_GT, COMPARE_LE, COMPARE_LT, DEFAULT_INEQ_SEL, examine_variable(), fb(), get_leftop(), get_op_opfamily_properties(), get_opfamily_member(), get_opfamily_method(), get_rightop(), get_variable_range(), GETSTRUCT(), HeapTupleIsValid, IndexAmTranslateCompareType(), IndexAmTranslateStrategy(), is_opclause(), OidIsValid, ReleaseVariableStats, root, and scalarineqsel().
Referenced by cached_scansel().
| Datum neqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3185 of file selfuncs.c.
References DatumGetFloat8(), DEFAULT_EQ_SEL, DirectFunctionCall5Coll(), eqjoinsel(), fb(), get_join_variables(), get_negator(), GETSTRUCT(), HeapTupleIsValid, Int16GetDatum(), JOIN_ANTI, JOIN_SEMI, ObjectIdGetDatum(), PG_GET_COLLATION, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, PointerGetDatum, ReleaseVariableStats, result, and root.
| Datum neqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 632 of file selfuncs.c.
References eqsel_internal(), and PG_RETURN_FLOAT8.
| Selectivity nulltestsel | ( | PlannerInfo * | root, |
| NullTestType | nulltesttype, | ||
| Node * | arg, | ||
| int | varRelid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 1784 of file selfuncs.c.
References arg, CLAMP_PROBABILITY, DEFAULT_NOT_UNK_SEL, DEFAULT_UNK_SEL, elog, ERROR, examine_variable(), fb(), GETSTRUCT(), HeapTupleIsValid, IS_NOT_NULL, IS_NULL, IsA, ReleaseVariableStats, and root.
Referenced by clause_selectivity_ext(), and clauselist_selectivity_ext().
| Selectivity rowcomparesel | ( | PlannerInfo * | root, |
| RowCompareExpr * | clause, | ||
| int | varRelid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 2320 of file selfuncs.c.
References fb(), join_selectivity(), RowCompareExpr::largs, linitial, linitial_oid, list_make2, NumRelids(), RowCompareExpr::rargs, restriction_selectivity(), root, and s1.
Referenced by clause_selectivity_ext().
| Selectivity scalararraysel | ( | PlannerInfo * | root, |
| ScalarArrayOpExpr * | clause, | ||
| bool | is_join_clause, | ||
| int | varRelid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 1902 of file selfuncs.c.
References ScalarArrayOpExpr::args, ARR_ELEMTYPE, array_contains_nulls(), Assert, CLAMP_PROBABILITY, DatumGetArrayTypeP, DatumGetFloat8(), deconstruct_array(), TypeCacheEntry::eq_opr, estimate_expression_value(), exprCollation(), exprType(), fb(), fmgr_info(), FunctionCall4Coll(), FunctionCall5Coll(), get_base_element_type(), get_negator(), get_oprjoin(), get_oprrest(), get_typlenbyval(), get_typlenbyvalalign(), i, Int16GetDatum(), Int32GetDatum(), IsA, lfirst, linitial, list_length(), list_make2, lookup_type_cache(), lsecond, makeConst(), makeNode, ObjectIdGetDatum(), OidIsValid, ScalarArrayOpExpr::opno, PointerGetDatum, root, s1, s2, scalararraysel_containment(), strip_array_coercion(), TYPECACHE_EQ_OPR, and ScalarArrayOpExpr::useOr.
Referenced by clause_selectivity_ext().
| Datum scalargejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3290 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
| Datum scalargesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1573 of file selfuncs.c.
References scalarineqsel_wrapper().
| Datum scalargtjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3281 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
| Datum scalargtsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1564 of file selfuncs.c.
References scalarineqsel_wrapper().
|
static |
Definition at line 655 of file selfuncs.c.
References CLAMP_PROBABILITY, DatumGetPointer(), DEFAULT_INEQ_SEL, fb(), fmgr_info(), get_opcode(), GETSTRUCT(), HeapTupleIsValid, ineq_histogram_selectivity(), IsA, ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumberNoCheck(), mcv_selectivity(), Min, root, and SelfItemPointerAttributeNumber.
Referenced by mergejoinscansel(), and scalarineqsel_wrapper().
|
static |
Definition at line 1475 of file selfuncs.c.
References DEFAULT_INEQ_SEL, fb(), get_commutator(), get_restriction_variable(), IsA, PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, ReleaseVariableStats, root, and scalarineqsel().
Referenced by scalargesel(), scalargtsel(), scalarlesel(), and scalarltsel().
| Datum scalarlejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3272 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
| Datum scalarlesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1555 of file selfuncs.c.
References scalarineqsel_wrapper().
| Datum scalarltjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3263 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
| Datum scalarltsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1546 of file selfuncs.c.
References scalarineqsel_wrapper().
| void spgcostestimate | ( | PlannerInfo * | root, |
| IndexPath * | path, | ||
| double | loop_count, | ||
| Cost * | indexStartupCost, | ||
| Cost * | indexTotalCost, | ||
| Selectivity * | indexSelectivity, | ||
| double * | indexCorrelation, | ||
| double * | indexPages | ||
| ) |
Definition at line 8379 of file selfuncs.c.
References cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, fb(), genericcostestimate(), GenericCosts::indexCorrelation, IndexPath::indexinfo, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, GenericCosts::numNonLeafPages, and root.
Referenced by spghandler().
| bool statistic_proc_security_check | ( | VariableStatData * | vardata, |
| Oid | func_oid | ||
| ) |
Definition at line 6684 of file selfuncs.c.
References DEBUG2, ereport, errmsg_internal(), fb(), get_func_leakproof(), get_func_name(), and OidIsValid.
Referenced by calc_arraycontsel(), calc_hist_selectivity(), calc_hist_selectivity(), eqjoinsel(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), scalararraysel_containment(), and var_eq_const().
|
static |
Definition at line 5990 of file selfuncs.c.
References contain_placeholder_walker(), fb(), root, and strip_all_phvs_mutator().
Referenced by examine_variable().
Definition at line 6022 of file selfuncs.c.
References expression_tree_mutator, fb(), IsA, and strip_all_phvs_mutator().
Referenced by strip_all_phvs_deep(), and strip_all_phvs_mutator().
Definition at line 1869 of file selfuncs.c.
References arg, fb(), and IsA.
Referenced by estimate_array_length(), and scalararraysel().
| double var_eq_const | ( | VariableStatData * | vardata, |
| Oid | oproid, | ||
| Oid | collation, | ||
| Datum | constval, | ||
| bool | constisnull, | ||
| bool | varonleft, | ||
| bool | negate | ||
| ) |
Definition at line 370 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, DatumGetBool(), fb(), fmgr_info(), free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), get_opcode(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, and statistic_proc_security_check().
Referenced by boolvarsel(), eqsel_internal(), patternsel_common(), and prefix_selectivity().
| double var_eq_non_const | ( | VariableStatData * | vardata, |
| Oid | oproid, | ||
| Oid | collation, | ||
| Node * | other, | ||
| bool | varonleft, | ||
| bool | negate | ||
| ) |
Definition at line 541 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, CLAMP_PROBABILITY, fb(), free_attstatsslot(), get_attstatsslot(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, and InvalidOid.
Referenced by eqsel_internal().
| get_index_stats_hook_type get_index_stats_hook = NULL |
Definition at line 184 of file selfuncs.c.
Referenced by brincostestimate(), examine_indexcol_variable(), and examine_variable().
| get_relation_stats_hook_type get_relation_stats_hook = NULL |
Definition at line 183 of file selfuncs.c.
Referenced by brincostestimate(), examine_indexcol_variable(), and examine_simple_variable().