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_am.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"
Go to the source code of this file.
Data Structures | |
struct | GroupVarInfo |
struct | GinQualCounts |
Macros | |
#define | DEFAULT_PAGE_CPU_MULTIPLIER 50.0 |
#define | VISITED_PAGES_LIMIT 100 |
Functions | |
static double | eqsel_internal (PG_FUNCTION_ARGS, bool negate) |
static double | eqjoinsel_inner (Oid opfuncoid, Oid collation, VariableStatData *vardata1, VariableStatData *vardata2, double nd1, double nd2, bool isdefault1, bool isdefault2, AttStatsSlot *sslot1, AttStatsSlot *sslot2, Form_pg_statistic stats1, Form_pg_statistic stats2, bool have_mcvs1, bool have_mcvs2) |
static double | eqjoinsel_semi (Oid opfuncoid, Oid collation, VariableStatData *vardata1, VariableStatData *vardata2, double nd1, double nd2, bool isdefault1, bool isdefault2, AttStatsSlot *sslot1, AttStatsSlot *sslot2, Form_pg_statistic stats1, Form_pg_statistic stats2, bool have_mcvs1, bool have_mcvs2, RelOptInfo *inner_rel) |
static bool | estimate_multivariate_ndistinct (PlannerInfo *root, RelOptInfo *rel, List **varinfos, double *ndistinct) |
static bool | convert_to_scalar (Datum value, Oid valuetypid, Oid collid, double *scaledvalue, Datum lobound, Datum hibound, Oid boundstypid, double *scaledlobound, double *scaledhibound) |
static double | convert_numeric_to_scalar (Datum value, Oid typid, bool *failure) |
static void | convert_string_to_scalar (char *value, double *scaledvalue, char *lobound, double *scaledlobound, char *hibound, double *scaledhibound) |
static void | convert_bytea_to_scalar (Datum value, double *scaledvalue, Datum lobound, double *scaledlobound, Datum hibound, double *scaledhibound) |
static double | convert_one_string_to_scalar (char *value, int rangelo, int rangehi) |
static double | convert_one_bytea_to_scalar (unsigned char *value, int valuelen, int rangelo, int rangehi) |
static char * | convert_string_datum (Datum value, Oid typid, Oid collid, bool *failure) |
static double | convert_timevalue_to_scalar (Datum value, Oid typid, bool *failure) |
static void | examine_simple_variable (PlannerInfo *root, Var *var, VariableStatData *vardata) |
static void | examine_indexcol_variable (PlannerInfo *root, IndexOptInfo *index, int indexcol, VariableStatData *vardata) |
static bool | get_variable_range (PlannerInfo *root, VariableStatData *vardata, Oid sortop, Oid collation, Datum *min, Datum *max) |
static void | get_stats_slot_range (AttStatsSlot *sslot, Oid opfuncoid, FmgrInfo *opproc, Oid collation, int16 typLen, bool typByVal, Datum *min, Datum *max, bool *p_have_data) |
static bool | get_actual_variable_range (PlannerInfo *root, VariableStatData *vardata, Oid sortop, Oid collation, Datum *min, Datum *max) |
static bool | get_actual_variable_endpoint (Relation heapRel, Relation indexRel, ScanDirection indexscandir, ScanKey scankeys, int16 typLen, bool typByVal, TupleTableSlot *tableslot, MemoryContext outercontext, Datum *endpointDatum) |
static RelOptInfo * | find_join_input_rel (PlannerInfo *root, Relids relids) |
static double | btcost_correlation (IndexOptInfo *index, VariableStatData *vardata) |
Datum | eqsel (PG_FUNCTION_ARGS) |
double | var_eq_const (VariableStatData *vardata, Oid oproid, Oid collation, Datum constval, bool constisnull, bool varonleft, bool negate) |
double | var_eq_non_const (VariableStatData *vardata, Oid oproid, Oid collation, Node *other, bool varonleft, bool negate) |
Datum | neqsel (PG_FUNCTION_ARGS) |
static double | scalarineqsel (PlannerInfo *root, Oid operator, bool isgt, bool iseq, Oid collation, VariableStatData *vardata, Datum constval, Oid consttype) |
double | mcv_selectivity (VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, double *sumcommonp) |
double | histogram_selectivity (VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, int min_hist_size, int n_skip, int *hist_size) |
double | generic_restriction_selectivity (PlannerInfo *root, Oid oproid, Oid collation, List *args, int varRelid, double default_selectivity) |
double | ineq_histogram_selectivity (PlannerInfo *root, VariableStatData *vardata, Oid opoid, FmgrInfo *opproc, bool isgt, bool iseq, Oid collation, Datum constval, Oid consttype) |
static Datum | scalarineqsel_wrapper (PG_FUNCTION_ARGS, bool isgt, bool iseq) |
Datum | scalarltsel (PG_FUNCTION_ARGS) |
Datum | scalarlesel (PG_FUNCTION_ARGS) |
Datum | scalargtsel (PG_FUNCTION_ARGS) |
Datum | scalargesel (PG_FUNCTION_ARGS) |
Selectivity | boolvarsel (PlannerInfo *root, Node *arg, int varRelid) |
Selectivity | booltestsel (PlannerInfo *root, BoolTestType booltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo) |
Selectivity | nulltestsel (PlannerInfo *root, NullTestType nulltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo) |
static Node * | strip_array_coercion (Node *node) |
Selectivity | scalararraysel (PlannerInfo *root, ScalarArrayOpExpr *clause, bool is_join_clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo) |
double | estimate_array_length (PlannerInfo *root, Node *arrayexpr) |
Selectivity | rowcomparesel (PlannerInfo *root, RowCompareExpr *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo) |
Datum | eqjoinsel (PG_FUNCTION_ARGS) |
Datum | neqjoinsel (PG_FUNCTION_ARGS) |
Datum | scalarltjoinsel (PG_FUNCTION_ARGS) |
Datum | scalarlejoinsel (PG_FUNCTION_ARGS) |
Datum | scalargtjoinsel (PG_FUNCTION_ARGS) |
Datum | scalargejoinsel (PG_FUNCTION_ARGS) |
void | mergejoinscansel (PlannerInfo *root, Node *clause, Oid opfamily, CompareType cmptype, bool nulls_first, Selectivity *leftstart, Selectivity *leftend, Selectivity *rightstart, Selectivity *rightend) |
Datum | matchingsel (PG_FUNCTION_ARGS) |
Datum | matchingjoinsel (PG_FUNCTION_ARGS) |
static List * | add_unique_group_var (PlannerInfo *root, List *varinfos, Node *var, VariableStatData *vardata) |
double | estimate_num_groups (PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo) |
List * | estimate_multivariate_bucketsize (PlannerInfo *root, RelOptInfo *inner, List *hashclauses, Selectivity *innerbucketsize) |
void | estimate_hash_bucket_stats (PlannerInfo *root, Node *hashkey, double nbuckets, Selectivity *mcv_freq, Selectivity *bucketsize_frac) |
double | estimate_hashagg_tablesize (PlannerInfo *root, Path *path, const AggClauseCosts *agg_costs, double dNumGroups) |
bool | get_restriction_variable (PlannerInfo *root, List *args, int varRelid, VariableStatData *vardata, Node **other, bool *varonleft) |
void | get_join_variables (PlannerInfo *root, List *args, SpecialJoinInfo *sjinfo, VariableStatData *vardata1, VariableStatData *vardata2, bool *join_is_reversed) |
static void | ReleaseDummy (HeapTuple tuple) |
void | examine_variable (PlannerInfo *root, Node *node, int varRelid, VariableStatData *vardata) |
bool | statistic_proc_security_check (VariableStatData *vardata, Oid func_oid) |
double | get_variable_numdistinct (VariableStatData *vardata, bool *isdefault) |
List * | get_quals_from_indexclauses (List *indexclauses) |
Cost | index_other_operands_eval_cost (PlannerInfo *root, List *indexquals) |
void | genericcostestimate (PlannerInfo *root, IndexPath *path, double loop_count, GenericCosts *costs) |
List * | add_predicate_to_index_quals (IndexOptInfo *index, List *indexQuals) |
void | btcostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
void | hashcostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
void | gistcostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
void | spgcostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
static bool | gincost_pattern (IndexOptInfo *index, int indexcol, Oid clause_op, Datum query, GinQualCounts *counts) |
static bool | gincost_opexpr (PlannerInfo *root, IndexOptInfo *index, int indexcol, OpExpr *clause, GinQualCounts *counts) |
static bool | gincost_scalararrayopexpr (PlannerInfo *root, IndexOptInfo *index, int indexcol, ScalarArrayOpExpr *clause, double numIndexEntries, GinQualCounts *counts) |
void | gincostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
void | brincostestimate (PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages) |
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 145 of file selfuncs.c.
#define VISITED_PAGES_LIMIT 100 |
List * add_predicate_to_index_quals | ( | IndexOptInfo * | index, |
List * | indexQuals | ||
) |
Definition at line 7093 of file selfuncs.c.
References lfirst, list_concat(), list_make1, NIL, and predicate_implied_by().
Referenced by btcostestimate(), genericcostestimate(), and gincostestimate().
|
static |
Definition at line 3316 of file selfuncs.c.
References equal(), exprs_known_equal(), foreach_delete_current, get_variable_numdistinct(), InvalidOid, GroupVarInfo::isdefault, lappend(), lfirst, GroupVarInfo::ndistinct, palloc(), GroupVarInfo::rel, VariableStatData::rel, remove_nulling_relids(), root, and GroupVarInfo::var.
Referenced by estimate_num_groups().
Selectivity booltestsel | ( | PlannerInfo * | root, |
BoolTestType | booltesttype, | ||
Node * | arg, | ||
int | varRelid, | ||
JoinType | jointype, | ||
SpecialJoinInfo * | sjinfo | ||
) |
Definition at line 1545 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(), free_attstatsslot(), get_attstatsslot(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, IS_FALSE, IS_NOT_FALSE, IS_NOT_TRUE, IS_NOT_UNKNOWN, IS_TRUE, IS_UNKNOWN, AttStatsSlot::nnumbers, AttStatsSlot::numbers, ReleaseVariableStats, root, VariableStatData::statsTuple, and AttStatsSlot::values.
Referenced by clause_selectivity_ext().
Selectivity boolvarsel | ( | PlannerInfo * | root, |
Node * | arg, | ||
int | varRelid | ||
) |
Definition at line 1517 of file selfuncs.c.
References arg, BoolGetDatum(), examine_variable(), HeapTupleIsValid, InvalidOid, ReleaseVariableStats, root, VariableStatData::statsTuple, 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 8466 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, free_attstatsslot(), VariableStatData::freefunc, 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, IndexClause::indexcol, IndexPath::indexinfo, Int16GetDatum(), InvalidOid, JOIN_INNER, lfirst_node, Max, Min, AttStatsSlot::nnumbers, NoLock, AttStatsSlot::numbers, ObjectIdGetDatum(), RelOptInfo::pages, BrinStatsData::pagesPerRange, planner_rt_fetch, ReleaseSysCache(), ReleaseVariableStats, RelOptInfo::relid, REVMAP_PAGE_MAXITEMS, BrinStatsData::revmapNumPages, root, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCache3(), and VariableStatData::statsTuple.
Referenced by brinhandler().
|
static |
Definition at line 7124 of file selfuncs.c.
References Assert(), ATTSTATSSLOT_NUMBERS, BTLessStrategyNumber, free_attstatsslot(), get_attstatsslot(), get_opfamily_member(), HeapTupleIsValid, AttStatsSlot::nnumbers, AttStatsSlot::numbers, OidIsValid, and VariableStatData::statsTuple.
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 7161 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(), genericcostestimate(), get_op_opfamily_strategy(), get_variable_numdistinct(), HeapTupleIsValid, IndexPath::indexclauses, IndexClause::indexcol, GenericCosts::indexCorrelation, IndexPath::indexinfo, IndexClause::indexquals, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, InvalidOid, IS_NULL, IsA, JOIN_INNER, lappend(), lfirst_node, linitial_oid, lsecond, Max, Min, NIL, nodeTag, NullTest::nulltesttype, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, GenericCosts::numIndexTuples, OidIsValid, OpExpr::opno, ScalarArrayOpExpr::opno, ReleaseVariableStats, root, and VariableStatData::statsTuple.
Referenced by bthandler().
|
static |
Definition at line 4938 of file selfuncs.c.
References convert_one_bytea_to_scalar(), DatumGetByteaPP, i, Min, value, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by convert_to_scalar().
Definition at line 4657 of file selfuncs.c.
References DatumGetBool(), DatumGetFloat4(), DatumGetFloat8(), DatumGetInt16(), DatumGetInt32(), DatumGetInt64(), DatumGetObjectId(), DirectFunctionCall1, numeric_float8_no_overflow(), and value.
Referenced by convert_to_scalar().
|
static |
Definition at line 4986 of file selfuncs.c.
References value.
Referenced by convert_bytea_to_scalar().
|
static |
Definition at line 4799 of file selfuncs.c.
References value.
Referenced by convert_string_to_scalar().
Definition at line 4850 of file selfuncs.c.
References Assert(), pg_locale_struct::collate_is_c, collid, DatumGetChar(), DatumGetPointer(), NameStr, 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 4719 of file selfuncs.c.
References convert_one_string_to_scalar(), and value.
Referenced by convert_to_scalar().
Definition at line 5029 of file selfuncs.c.
References date2timestamp_no_overflow(), DatumGetDateADT(), DatumGetIntervalP(), DatumGetTimeADT(), DatumGetTimestamp(), DatumGetTimestampTz(), DatumGetTimeTzADTP(), DAYS_PER_YEAR, interval::month, MONTHS_PER_YEAR, TimeTzADT::time, interval::time, USECS_PER_DAY, value, and TimeTzADT::zone.
Referenced by convert_to_scalar().
|
static |
Definition at line 4510 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(), pfree(), and value.
Referenced by ineq_histogram_selectivity().
Datum eqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2277 of file selfuncs.c.
References generate_unaccent_rules::args, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, elog, eqjoinsel_inner(), eqjoinsel_semi(), ERROR, find_join_input_rel(), free_attstatsslot(), get_attstatsslot(), get_commutator(), get_join_variables(), get_opcode(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, JOIN_ANTI, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, SpecialJoinInfo::jointype, Min, SpecialJoinInfo::min_righthand, OidIsValid, PG_GET_COLLATION, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, ReleaseVariableStats, root, RelOptInfo::rows, statistic_proc_security_check(), and VariableStatData::statsTuple.
Referenced by neqjoinsel().
|
static |
Definition at line 2442 of file selfuncs.c.
References CLAMP_PROBABILITY, DatumGetBool(), fmgr_info(), FunctionCallInvoke, i, InitFunctionCallInfoData, j, LOCAL_FCINFO, AttStatsSlot::numbers, AttStatsSlot::nvalues, palloc0(), pfree(), and AttStatsSlot::values.
Referenced by eqjoinsel().
|
static |
Definition at line 2639 of file selfuncs.c.
References CLAMP_PROBABILITY, DatumGetBool(), fmgr_info(), FunctionCallInvoke, i, InitFunctionCallInfoData, j, LOCAL_FCINFO, Min, AttStatsSlot::numbers, AttStatsSlot::nvalues, OidIsValid, palloc0(), pfree(), VariableStatData::rel, RelOptInfo::rows, and AttStatsSlot::values.
Referenced by eqjoinsel().
Datum eqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 232 of file selfuncs.c.
References eqsel_internal(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 241 of file selfuncs.c.
References generate_unaccent_rules::args, DEFAULT_EQ_SEL, 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 2144 of file selfuncs.c.
References ARR_DIMS, ARR_NDIM, ArrayGetNItems(), ATTSTATSSLOT_NUMBERS, clamp_row_est(), DatumGetArrayTypeP, examine_variable(), free_attstatsslot(), get_attstatsslot(), HeapTupleIsValid, InvalidOid, IsA, list_length(), AttStatsSlot::nnumbers, AttStatsSlot::numbers, ReleaseVariableStats, root, VariableStatData::statsTuple, 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 4003 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, clamp_row_est(), examine_variable(), free_attstatsslot(), get_attstatsslot(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, Max, AttStatsSlot::nnumbers, AttStatsSlot::numbers, VariableStatData::rel, ReleaseVariableStats, root, RelOptInfo::rows, VariableStatData::statsTuple, and RelOptInfo::tuples.
Referenced by final_cost_hashjoin().
double estimate_hashagg_tablesize | ( | PlannerInfo * | root, |
Path * | path, | ||
const AggClauseCosts * | agg_costs, | ||
double | dNumGroups | ||
) |
Definition at line 4122 of file selfuncs.c.
References hash_agg_entry_size(), list_length(), root, and AggClauseCosts::transitionSpace.
Referenced by consider_groupingsets_paths().
List * estimate_multivariate_bucketsize | ( | PlannerInfo * | root, |
RelOptInfo * | inner, | ||
List * | hashclauses, | ||
Selectivity * | innerbucketsize | ||
) |
Definition at line 3798 of file selfuncs.c.
References Assert(), bms_get_singleton_member(), RestrictInfo::clause, estimate_multivariate_ndistinct(), forboth, foreach_delete_current, get_leftop(), get_rightop(), GroupVarInfo::isdefault, lappend(), lfirst, lfirst_node, list_concat(), list_copy(), list_free(), list_free_deep(), list_length(), list_member_ptr(), GroupVarInfo::ndistinct, NIL, palloc(), GroupVarInfo::rel, root, and GroupVarInfo::var.
Referenced by final_cost_hashjoin().
|
static |
Definition at line 4159 of file selfuncs.c.
References Assert(), attnum, MVNDistinctItem::attributes, AttrNumberIsForUserDefinedAttr, bms_add_member(), bms_is_member(), bms_num_members(), elog, equal(), ERROR, StatisticExtInfo::exprs, i, idx(), RangeTblEntry::inh, StatisticExtInfo::inherit, InvalidOid, IsA, MVNDistinct::items, j, StatisticExtInfo::keys, StatisticExtInfo::kind, lappend(), lfirst, list_length(), MVNDistinctItem::nattributes, MVNDistinctItem::ndistinct, NIL, MVNDistinct::nitems, planner_rt_fetch, GroupVarInfo::rel, RelOptInfo::relid, root, statext_ndistinct_load(), RelOptInfo::statlist, StatisticExtInfo::statOid, and GroupVarInfo::var.
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 3446 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(), EstimationInfo::flags, for_each_from, HeapTupleIsValid, i, IS_SIMPLE_REL, GroupVarInfo::isdefault, VariableStatData::isunique, lappend(), lfirst, linitial, list_member_int(), GroupVarInfo::ndistinct, NIL, pull_var_clause(), PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, GroupVarInfo::rel, ReleaseVariableStats, root, RelOptInfo::rows, SELFLAG_USED_DEFAULT, VariableStatData::statsTuple, and RelOptInfo::tuples.
Referenced by adjust_rowcount_for_semijoins(), build_setop_child_paths(), cost_incremental_sort(), cost_memoize_rescan(), create_final_distinct_paths(), create_partial_distinct_paths(), create_unique_path(), estimate_path_cost_size(), get_number_of_groups(), and get_windowclause_startup_tuples().
|
static |
Definition at line 5983 of file selfuncs.c.
References Assert(), BoolGetDatum(), elog, ERROR, VariableStatData::freefunc, get_index_stats_hook, get_relation_stats_hook, HeapTupleIsValid, RangeTblEntry::inh, Int16GetDatum(), InvalidOid, ObjectIdGetDatum(), planner_rt_fetch, VariableStatData::rel, ReleaseSysCache(), root, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCache3(), and VariableStatData::statsTuple.
Referenced by btcostestimate().
|
static |
Definition at line 5631 of file selfuncs.c.
References VariableStatData::acl_ok, ACL_SELECT, ACLCHECK_OK, Assert(), BoolGetDatum(), RTEPermissionInfo::checkAsUser, PlannerInfo::cte_plan_ids, RangeTblEntry::ctelevelsup, Query::cteList, RangeTblEntry::ctename, CommonTableExpr::ctename, Query::distinctClause, elog, ERROR, examine_simple_variable(), TargetEntry::expr, find_base_rel(), find_base_rel_noerr(), VariableStatData::freefunc, get_relation_stats_hook, get_tle_by_resno(), getRTEPermissionInfo(), GetUserId(), Query::groupClause, Query::groupingSets, HeapTupleIsValid, if(), RangeTblEntry::inh, Int16GetDatum(), InvalidAttrNumber, InvalidOid, IsA, VariableStatData::isunique, lfirst, list_length(), list_nth(), list_nth_int(), NIL, AppendRelInfo::num_child_cols, ObjectIdGetDatum(), OidIsValid, AppendRelInfo::parent_relid, PlannerInfo::parse, pg_attribute_aclcheck(), pg_class_aclcheck(), planner_rt_fetch, ReleaseSysCache(), Query::returningList, root, RTE_CTE, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, SearchSysCache3(), Query::setOperations, VariableStatData::statsTuple, RelOptInfo::subroot, targetIsInSortList(), Query::targetList, RelOptInfo::userid, 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 5224 of file selfuncs.c.
References VariableStatData::acl_ok, ACL_SELECT, ACLCHECK_OK, arg, Assert(), VariableStatData::atttype, VariableStatData::atttypmod, 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(), find_base_rel(), find_join_rel(), VariableStatData::freefunc, get_index_stats_hook, GetUserId(), has_unique_index(), HeapTupleIsValid, if(), RelOptInfo::indexlist, RangeTblEntry::inh, StatisticExtInfo::inherit, Int16GetDatum(), IsA, VariableStatData::isunique, StatisticExtInfo::kind, lfirst, list_head(), lnext(), MemSet, NIL, ObjectIdGetDatum(), OidIsValid, AppendRelInfo::parent_relid, pg_class_aclcheck(), planner_rt_fetch, pull_varnos(), VariableStatData::rel, ReleaseDummy(), ReleaseSysCache(), RelOptInfo::relid, remove_nulling_relids(), root, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCache3(), statext_expressions_load(), RelOptInfo::statlist, StatisticExtInfo::statOid, VariableStatData::statsTuple, RelOptInfo::userid, VariableStatData::var, Var::varattno, Var::varno, and VariableStatData::vartype.
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 6754 of file selfuncs.c.
References bms_get_singleton_member(), bms_is_empty, elog, ERROR, 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 919 of file selfuncs.c.
References generate_unaccent_rules::args, CLAMP_PROBABILITY, fmgr_info(), get_opcode(), get_restriction_variable(), GETSTRUCT(), HeapTupleIsValid, histogram_selectivity(), IsA, mcv_selectivity(), ReleaseVariableStats, root, and VariableStatData::statsTuple.
Referenced by ltreeparentsel(), and matchingsel().
void genericcostestimate | ( | PlannerInfo * | root, |
IndexPath * | path, | ||
double | loop_count, | ||
GenericCosts * | costs | ||
) |
Definition at line 6870 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(), 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, root, and GenericCosts::spc_random_page_cost.
Referenced by blcostestimate(), btcostestimate(), gistcostestimate(), hashcostestimate(), and spgcostestimate().
|
static |
Definition at line 6589 of file selfuncs.c.
References datumCopy(), elog, ERROR, ExecClearTuple(), 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(), values, VISITED_PAGES_LIMIT, VM_ALL_VISIBLE, IndexScanDescData::xs_itup, IndexScanDescData::xs_itupdesc, IndexScanDescData::xs_recheck, and IndexScanDescData::xs_want_itup.
Referenced by get_actual_variable_range().
|
static |
Definition at line 6407 of file selfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), VariableStatData::atttype, BackwardScanDirection, COMPARE_GT, COMPARE_LT, CurrentMemoryContext, ExecDropSingleTupleTableSlot(), 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(), MemoryContextDelete(), MemoryContextSwitchTo(), NIL, NoLock, VariableStatData::rel, RelOptInfo::relid, root, RTE_RELATION, RangeTblEntry::rtekind, ScanKeyEntryInitialize(), SK_ISNULL, SK_SEARCHNOTNULL, table_close(), table_open(), table_slot_create(), and VariableStatData::var.
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 5155 of file selfuncs.c.
References generate_unaccent_rules::args, bms_is_subset(), elog, ERROR, examine_variable(), linitial, list_length(), lsecond, VariableStatData::rel, RelOptInfo::relids, root, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by eqjoinsel(), neqjoinsel(), and networkjoinsel().
Definition at line 6786 of file selfuncs.c.
References IndexClause::indexquals, lappend(), lfirst_node, and NIL.
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 5095 of file selfuncs.c.
References generate_unaccent_rules::args, estimate_expression_value(), examine_variable(), linitial, list_length(), lsecond, VariableStatData::rel, ReleaseVariableStats, root, and VariableStatData::var.
Referenced by _int_matchsel(), arraycontsel(), eqsel_internal(), generic_restriction_selectivity(), multirangesel(), networksel(), patternsel_common(), rangesel(), scalarineqsel_wrapper(), and tsmatchsel().
|
static |
Definition at line 6344 of file selfuncs.c.
References datumCopy(), DatumGetBool(), fmgr_info(), FmgrInfo::fn_oid, FunctionCall2Coll(), i, AttStatsSlot::nvalues, and AttStatsSlot::values.
Referenced by get_variable_range().
double get_variable_numdistinct | ( | VariableStatData * | vardata, |
bool * | isdefault | ||
) |
Definition at line 6084 of file selfuncs.c.
References clamp_row_est(), DEFAULT_NUM_DISTINCT, GETSTRUCT(), HeapTupleIsValid, IsA, VariableStatData::isunique, VariableStatData::rel, RTE_VALUES, RelOptInfo::rtekind, SelfItemPointerAttributeNumber, VariableStatData::statsTuple, TableOidAttributeNumber, RelOptInfo::tuples, VariableStatData::var, and VariableStatData::vartype.
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 6217 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, VariableStatData::atttype, datumCopy(), FmgrInfo::fn_oid, free_attstatsslot(), get_actual_variable_range(), get_attstatsslot(), get_opcode(), get_stats_slot_range(), get_typlenbyval(), GETSTRUCT(), HeapTupleIsValid, i, InvalidOid, AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::nvalues, root, AttStatsSlot::stacoll, statistic_proc_security_check(), VariableStatData::statsTuple, and AttStatsSlot::values.
Referenced by mergejoinscansel().
|
static |
Definition at line 7910 of file selfuncs.c.
References arg, OpExpr::args, estimate_expression_value(), GinQualCounts::exactEntries, gincost_pattern(), IsA, lsecond, OpExpr::opno, root, and GinQualCounts::searchEntries.
Referenced by gincostestimate().
|
static |
Definition at line 7796 of file selfuncs.c.
References Assert(), GinQualCounts::attHasFullScan, GinQualCounts::attHasNormalScan, elog, ERROR, GinQualCounts::exactEntries, 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 7960 of file selfuncs.c.
References arg, ScalarArrayOpExpr::args, ARR_ELEMTYPE, GinQualCounts::arrayScans, Assert(), GinQualCounts::attHasFullScan, GinQualCounts::attHasNormalScan, DatumGetArrayTypeP, deconstruct_array(), estimate_array_length(), estimate_expression_value(), GinQualCounts::exactEntries, 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 8076 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, 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, IndexClause::indexcol, IndexPath::indexinfo, IndexClause::indexquals, IsA, JOIN_INNER, lfirst_node, list_length(), Max, Min, GinStatsData::nDataPages, GinStatsData::nEntries, GinStatsData::nEntryPages, NIL, nodeTag, NoLock, GinStatsData::nPendingPages, GinStatsData::nTotalPages, 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 7666 of file selfuncs.c.
References cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, genericcostestimate(), GenericCosts::indexCorrelation, IndexPath::indexinfo, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, and root.
Referenced by gisthandler().
void hashcostestimate | ( | PlannerInfo * | root, |
IndexPath * | path, | ||
double | loop_count, | ||
Cost * | indexStartupCost, | ||
Cost * | indexTotalCost, | ||
Selectivity * | indexSelectivity, | ||
double * | indexCorrelation, | ||
double * | indexPages | ||
) |
Definition at line 7624 of file selfuncs.c.
References genericcostestimate(), GenericCosts::indexCorrelation, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::numIndexPages, 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 828 of file selfuncs.c.
References Assert(), ATTSTATSSLOT_VALUES, DatumGetBool(), FmgrInfo::fn_oid, free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, AttStatsSlot::nvalues, statistic_proc_security_check(), VariableStatData::statsTuple, and AttStatsSlot::values.
Referenced by generic_restriction_selectivity(), and patternsel_common().
Cost index_other_operands_eval_cost | ( | PlannerInfo * | root, |
List * | indexquals | ||
) |
Definition at line 6816 of file selfuncs.c.
References OpExpr::args, ScalarArrayOpExpr::args, cost_qual_eval_node(), elog, ERROR, IsA, lfirst, lsecond, nodeTag, QualCost::per_tuple, RowCompareExpr::rargs, root, and QualCost::startup.
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 1046 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, comparison_ops_are_compatible(), convert_to_scalar(), DatumGetBool(), FmgrInfo::fn_oid, free_attstatsslot(), FunctionCall2Coll(), FunctionCallInvoke, get_actual_variable_range(), get_attstatsslot(), get_variable_numdistinct(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, AttStatsSlot::nnumbers, AttStatsSlot::nvalues, root, AttStatsSlot::stacoll, AttStatsSlot::staop, statistic_proc_security_check(), VariableStatData::statsTuple, val, AttStatsSlot::values, and VariableStatData::vartype.
Referenced by prefix_selectivity(), and scalarineqsel().
Datum matchingjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3295 of file selfuncs.c.
References DEFAULT_MATCHING_SEL, and PG_RETURN_FLOAT8.
Datum matchingsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3277 of file selfuncs.c.
References generate_unaccent_rules::args, DEFAULT_MATCHING_SEL, 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 737 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetBool(), FmgrInfo::fn_oid, free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, AttStatsSlot::numbers, AttStatsSlot::nvalues, statistic_proc_security_check(), VariableStatData::statsTuple, and AttStatsSlot::values.
Referenced by generic_restriction_selectivity(), networksel(), patternsel_common(), and scalarineqsel().
void mergejoinscansel | ( | PlannerInfo * | root, |
Node * | clause, | ||
Oid | opfamily, | ||
CompareType | cmptype, | ||
bool | nulls_first, | ||
Selectivity * | leftstart, | ||
Selectivity * | leftend, | ||
Selectivity * | rightstart, | ||
Selectivity * | rightend | ||
) |
Definition at line 2960 of file selfuncs.c.
References Assert(), CLAMP_PROBABILITY, COMPARE_EQ, COMPARE_GE, COMPARE_GT, COMPARE_LE, COMPARE_LT, DEFAULT_INEQ_SEL, examine_variable(), 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, scalarineqsel(), and VariableStatData::statsTuple.
Referenced by cached_scansel().
Datum neqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2827 of file selfuncs.c.
References generate_unaccent_rules::args, DatumGetFloat8(), DEFAULT_EQ_SEL, DirectFunctionCall5Coll(), eqjoinsel(), 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, root, and VariableStatData::statsTuple.
Datum neqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 562 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 1703 of file selfuncs.c.
References arg, CLAMP_PROBABILITY, DEFAULT_NOT_UNK_SEL, DEFAULT_UNK_SEL, elog, ERROR, examine_variable(), GETSTRUCT(), HeapTupleIsValid, IS_NOT_NULL, IS_NULL, IsA, ReleaseVariableStats, root, VariableStatData::statsTuple, and VariableStatData::var.
Referenced by clause_selectivity_ext(), and clauselist_selectivity_ext().
|
static |
Selectivity rowcomparesel | ( | PlannerInfo * | root, |
RowCompareExpr * | clause, | ||
int | varRelid, | ||
JoinType | jointype, | ||
SpecialJoinInfo * | sjinfo | ||
) |
Definition at line 2210 of file selfuncs.c.
References 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 1821 of file selfuncs.c.
References generate_unaccent_rules::args, ScalarArrayOpExpr::args, ARR_ELEMTYPE, Assert(), CLAMP_PROBABILITY, DatumGetArrayTypeP, DatumGetFloat8(), deconstruct_array(), TypeCacheEntry::eq_opr, estimate_expression_value(), exprCollation(), exprType(), 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, CaseTestExpr::typeId, and ScalarArrayOpExpr::useOr.
Referenced by clause_selectivity_ext().
Datum scalargejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2932 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
Datum scalargesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1503 of file selfuncs.c.
References scalarineqsel_wrapper().
Datum scalargtjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2923 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
Datum scalargtsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1494 of file selfuncs.c.
References scalarineqsel_wrapper().
|
static |
Definition at line 585 of file selfuncs.c.
References CLAMP_PROBABILITY, DatumGetPointer(), DEFAULT_INEQ_SEL, fmgr_info(), get_opcode(), GETSTRUCT(), HeapTupleIsValid, ineq_histogram_selectivity(), IsA, ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumberNoCheck(), mcv_selectivity(), Min, RelOptInfo::pages, VariableStatData::rel, root, SelfItemPointerAttributeNumber, VariableStatData::statsTuple, RelOptInfo::tuples, and VariableStatData::var.
Referenced by mergejoinscansel(), and scalarineqsel_wrapper().
|
static |
Definition at line 1405 of file selfuncs.c.
References generate_unaccent_rules::args, DEFAULT_INEQ_SEL, 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 2914 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
Datum scalarlesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1485 of file selfuncs.c.
References scalarineqsel_wrapper().
Datum scalarltjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2905 of file selfuncs.c.
References DEFAULT_INEQ_SEL, and PG_RETURN_FLOAT8.
Datum scalarltsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1476 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 7721 of file selfuncs.c.
References cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, genericcostestimate(), GenericCosts::indexCorrelation, IndexPath::indexinfo, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, GenericCosts::num_sa_scans, GenericCosts::numIndexPages, and root.
Referenced by spghandler().
bool statistic_proc_security_check | ( | VariableStatData * | vardata, |
Oid | func_oid | ||
) |
Definition at line 6055 of file selfuncs.c.
References VariableStatData::acl_ok, DEBUG2, ereport, errmsg_internal(), get_func_leakproof(), get_func_name(), and OidIsValid.
Referenced by calc_arraycontsel(), calc_hist_selectivity(), eqjoinsel(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), scalararraysel_containment(), and var_eq_const().
Definition at line 1788 of file selfuncs.c.
References arg, ArrayCoerceExpr::arg, ArrayCoerceExpr::elemexpr, 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 300 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, DatumGetBool(), fmgr_info(), free_attstatsslot(), FunctionCallInvoke, get_attstatsslot(), get_opcode(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, i, InitFunctionCallInfoData, InvalidOid, VariableStatData::isunique, LOCAL_FCINFO, AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::nvalues, VariableStatData::rel, statistic_proc_security_check(), VariableStatData::statsTuple, RelOptInfo::tuples, and AttStatsSlot::values.
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 471 of file selfuncs.c.
References ATTSTATSSLOT_NUMBERS, CLAMP_PROBABILITY, free_attstatsslot(), get_attstatsslot(), get_variable_numdistinct(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, VariableStatData::isunique, AttStatsSlot::nnumbers, AttStatsSlot::numbers, VariableStatData::rel, VariableStatData::statsTuple, and RelOptInfo::tuples.
Referenced by eqsel_internal().
get_index_stats_hook_type get_index_stats_hook = NULL |
Definition at line 149 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 148 of file selfuncs.c.
Referenced by brincostestimate(), examine_indexcol_variable(), and examine_simple_variable().