PostgreSQL Source Code: src/include/utils/selfuncs.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef SELFUNCS_H
16#define SELFUNCS_H
17
21
22
23
24
25
26
27
28
29
30
31
32
33
34#define DEFAULT_EQ_SEL 0.005
35
36
37#define DEFAULT_INEQ_SEL 0.3333333333333333
38
39
40#define DEFAULT_RANGE_INEQ_SEL 0.005
41
42
43#define DEFAULT_MULTIRANGE_INEQ_SEL 0.005
44
45
46#define DEFAULT_MATCH_SEL 0.005
47
48
49#define DEFAULT_MATCHING_SEL 0.010
50
51
52#define DEFAULT_NUM_DISTINCT 200
53
54
55#define DEFAULT_UNK_SEL 0.005
56#define DEFAULT_NOT_UNK_SEL (1.0 - DEFAULT_UNK_SEL)
57
58
59
60
61
62
63#define CLAMP_PROBABILITY(p) \
64 do { \
65 if (p < 0.0) \
66 p = 0.0; \
67 else if (p > 1.0) \
68 p = 1.0; \
69 } while (0)
70
71
72
73
74
75
76#define SELFLAG_USED_DEFAULT (1 << 0)
77
79
81{
83
86
90 RelOptInfo *rel;
99 bool acl_ok;
101
102#define ReleaseVariableStats(vardata) \
103 do { \
104 if (HeapTupleIsValid((vardata).statsTuple)) \
105 (vardata).freefunc((vardata).statsTuple); \
106 } while(0)
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
124
125typedef struct
130 Selectivity indexSelectivity;
131 double indexCorrelation;
134 double numIndexPages;
135 double numIndexTuples;
136 double spc_random_page_cost;
137 double num_sa_scans;
140
147 Oid indexOid,
151
152
153
158 int varRelid,
160 bool *varonleft);
165 bool *join_is_reversed);
167 bool *isdefault);
170 Datum constval, bool varonleft,
171 double *sumcommonp);
174 Datum constval, bool varonleft,
175 int min_hist_size, int n_skip,
176 int *hist_size);
178 Oid oproid, Oid collation,
180 double default_selectivity);
184 bool isgt, bool iseq,
185 Oid collation,
186 Datum constval, Oid consttype);
188 Oid oproid, Oid collation,
189 Datum constval, bool constisnull,
190 bool varonleft, bool negate);
192 Oid oproid, Oid collation,
194 bool varonleft, bool negate);
195
205 bool is_join_clause,
211
216
218 double input_rows, List **pgset,
220
223 List *hashclauses,
226 Node *hashkey, double nbuckets,
231 double dNumGroups);
232
235 List *indexquals);
237 List *indexQuals);
239 double loop_count,
241
242
243
246 Oid elemtype, bool isEquality, bool useOr,
247 int varRelid);
248
249#endif
Selectivity scalararraysel_containment(PlannerInfo *root, Node *leftop, Node *rightop, Oid elemtype, bool isEquality, bool useOr, int varRelid)
bool get_restriction_variable(PlannerInfo *root, List *args, int varRelid, VariableStatData *vardata, Node **other, bool *varonleft)
void mergejoinscansel(PlannerInfo *root, Node *clause, Oid opfamily, CompareType cmptype, bool nulls_first, Selectivity *leftstart, Selectivity *leftend, Selectivity *rightstart, Selectivity *rightend)
List * get_quals_from_indexclauses(List *indexclauses)
double var_eq_const(VariableStatData *vardata, Oid oproid, Oid collation, Datum constval, bool constisnull, bool varonleft, bool negate)
List * add_predicate_to_index_quals(IndexOptInfo *index, List *indexQuals)
double generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation, List *args, int varRelid, double default_selectivity)
Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
double estimate_array_length(PlannerInfo *root, Node *arrayexpr)
double mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, double *sumcommonp)
Selectivity nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
PGDLLIMPORT get_relation_stats_hook_type get_relation_stats_hook
struct VariableStatData VariableStatData
void examine_variable(PlannerInfo *root, Node *node, int varRelid, VariableStatData *vardata)
bool(* get_relation_stats_hook_type)(PlannerInfo *root, RangeTblEntry *rte, AttrNumber attnum, VariableStatData *vardata)
struct EstimationInfo EstimationInfo
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
double ineq_histogram_selectivity(PlannerInfo *root, VariableStatData *vardata, Oid opoid, FmgrInfo *opproc, bool isgt, bool iseq, Oid collation, Datum constval, Oid consttype)
void genericcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, GenericCosts *costs)
List * estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner, List *hashclauses, Selectivity *innerbucketsize)
bool(* get_index_stats_hook_type)(PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata)
double histogram_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, int min_hist_size, int n_skip, int *hist_size)
Selectivity boolvarsel(PlannerInfo *root, Node *arg, int varRelid)
Selectivity scalararraysel(PlannerInfo *root, ScalarArrayOpExpr *clause, bool is_join_clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
double var_eq_non_const(VariableStatData *vardata, Oid oproid, Oid collation, Node *other, bool varonleft, bool negate)
double get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook
bool statistic_proc_security_check(VariableStatData *vardata, Oid func_oid)
double estimate_hashagg_tablesize(PlannerInfo *root, Path *path, const AggClauseCosts *agg_costs, double dNumGroups)
void estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets, Selectivity *mcv_freq, Selectivity *bucketsize_frac)
Cost index_other_operands_eval_cost(PlannerInfo *root, List *indexquals)
Selectivity rowcomparesel(PlannerInfo *root, RowCompareExpr *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
void get_join_variables(PlannerInfo *root, List *args, SpecialJoinInfo *sjinfo, VariableStatData *vardata1, VariableStatData *vardata2, bool *join_is_reversed)
void(* freefunc)(HeapTuple tuple)