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 "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 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) |
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, int strategy, 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) |
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 144 of file selfuncs.c.
#define VISITED_PAGES_LIMIT 100 |
List* add_predicate_to_index_quals | ( | IndexOptInfo * | index, |
List * | indexQuals | ||
) |
Definition at line 6775 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 3296 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, 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 1540 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 1512 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 7981 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, RangeTblEntry::relid, RelOptInfo::relid, REVMAP_PAGE_MAXITEMS, BrinStatsData::revmapNumPages, root, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCache3(), and VariableStatData::statsTuple.
Referenced by brinhandler().
void btcostestimate | ( | PlannerInfo * | root, |
IndexPath * | path, | ||
double | loop_count, | ||
Cost * | indexStartupCost, | ||
Cost * | indexTotalCost, | ||
Selectivity * | indexSelectivity, | ||
double * | indexCorrelation, | ||
double * | indexPages | ||
) |
Definition at line 6796 of file selfuncs.c.
References add_predicate_to_index_quals(), ScalarArrayOpExpr::args, Assert, ATTSTATSSLOT_NUMBERS, BoolGetDatum(), BTEqualStrategyNumber, BTLessStrategyNumber, RestrictInfo::clause, clauselist_selectivity(), cpu_operator_cost, DEFAULT_PAGE_CPU_MULTIPLIER, elog, ERROR, estimate_array_length(), free_attstatsslot(), VariableStatData::freefunc, genericcostestimate(), get_attstatsslot(), get_index_stats_hook, get_op_opfamily_strategy(), get_opfamily_member(), get_relation_stats_hook, HeapTupleIsValid, IndexPath::indexclauses, IndexClause::indexcol, GenericCosts::indexCorrelation, IndexPath::indexinfo, IndexClause::indexquals, GenericCosts::indexSelectivity, GenericCosts::indexStartupCost, GenericCosts::indexTotalCost, RangeTblEntry::inh, Int16GetDatum(), InvalidOid, IS_NULL, IsA, JOIN_INNER, lappend(), lfirst_node, linitial_oid, lsecond, Max, Min, NIL, AttStatsSlot::nnumbers, nodeTag, NullTest::nulltesttype, GenericCosts::num_sa_scans, AttStatsSlot::numbers, GenericCosts::numIndexPages, GenericCosts::numIndexTuples, ObjectIdGetDatum(), OidIsValid, OpExpr::opno, ScalarArrayOpExpr::opno, planner_rt_fetch, ReleaseSysCache(), ReleaseVariableStats, RangeTblEntry::relid, root, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCache3(), and VariableStatData::statsTuple.
Referenced by bthandler().
|
static |
Definition at line 4734 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 4453 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 4782 of file selfuncs.c.
References value.
Referenced by convert_bytea_to_scalar().
|
static |
Definition at line 4595 of file selfuncs.c.
References value.
Referenced by convert_string_to_scalar().
Definition at line 4646 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 4515 of file selfuncs.c.
References convert_one_string_to_scalar(), and value.
Referenced by convert_to_scalar().
Definition at line 4825 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 4306 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 2269 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 2434 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 2631 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 | ) |
|
static |
Definition at line 236 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 2136 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 3799 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 3918 of file selfuncs.c.
References hash_agg_entry_size(), list_length(), root, and AggClauseCosts::transitionSpace.
Referenced by consider_groupingsets_paths().
|
static |
Definition at line 3955 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_num_groups().
double estimate_num_groups | ( | PlannerInfo * | root, |
List * | groupExprs, | ||
double | input_rows, | ||
List ** | pgset, | ||
EstimationInfo * | estinfo | ||
) |
Definition at line 3417 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 5414 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, 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(), RangeTblEntry::relid, 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_variable().
void examine_variable | ( | PlannerInfo * | root, |
Node * | node, | ||
int | varRelid, | ||
VariableStatData * | vardata | ||
) |
Definition at line 5020 of file selfuncs.c.
References VariableStatData::acl_ok, ACL_SELECT, ACLCHECK_OK, arg, Assert, VariableStatData::atttype, VariableStatData::atttypmod, bms_free(), bms_get_singleton_member(), bms_is_empty, bms_is_member(), 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(), RangeTblEntry::relid, RelOptInfo::relid, 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 6436 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 914 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 6552 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 6275 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 6095 of file selfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, VariableStatData::atttype, BackwardScanDirection, BTGreaterStrategyNumber, BTLessStrategyNumber, CurrentMemoryContext, ExecDropSingleTupleTableSlot(), ForwardScanDirection, get_actual_variable_endpoint(), get_op_opfamily_strategy(), get_typlenbyval(), index_close(), index_open(), RelOptInfo::indexlist, InvalidOid, InvalidStrategy, lfirst, match_index_to_operand(), MemoryContextDelete(), MemoryContextSwitchTo(), NIL, NoLock, VariableStatData::rel, RangeTblEntry::relid, 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 4951 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 6468 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 4891 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().