| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef EXTENDED_STATS_INTERNAL_H |
| #define EXTENDED_STATS_INTERNAL_H |
|
|
| #include "statistics/statistics.h" |
| #include "utils/sortsupport.h" |
|
|
| typedef struct |
| { |
| Oid eqopr; |
| Oid eqfunc; |
| Oid ltopr; |
| } StdAnalyzeData; |
|
|
| typedef struct |
| { |
| Datum value; |
| int tupno; |
| } ScalarItem; |
|
|
| |
| typedef struct DimensionInfo |
| { |
| int nvalues; |
| int nbytes; |
| int nbytes_aligned; |
| int typlen; |
| bool typbyval; |
| } DimensionInfo; |
|
|
| |
| typedef struct MultiSortSupportData |
| { |
| int ndims; |
| |
| SortSupportData ssup[FLEXIBLE_ARRAY_MEMBER]; |
| } MultiSortSupportData; |
|
|
| typedef MultiSortSupportData *MultiSortSupport; |
|
|
| typedef struct SortItem |
| { |
| Datum *values; |
| bool *isnull; |
| int count; |
| } SortItem; |
|
|
| |
| typedef struct StatsBuildData |
| { |
| int numrows; |
| int nattnums; |
| AttrNumber *attnums; |
| VacAttrStats **stats; |
| Datum **values; |
| bool **nulls; |
| } StatsBuildData; |
|
|
|
|
| extern MVNDistinct *statext_ndistinct_build(double totalrows, StatsBuildData *data); |
| extern bytea *statext_ndistinct_serialize(MVNDistinct *ndistinct); |
| extern MVNDistinct *statext_ndistinct_deserialize(bytea *data); |
|
|
| extern MVDependencies *statext_dependencies_build(StatsBuildData *data); |
| extern bytea *statext_dependencies_serialize(MVDependencies *dependencies); |
| extern MVDependencies *statext_dependencies_deserialize(bytea *data); |
|
|
| extern MCVList *statext_mcv_build(StatsBuildData *data, |
| double totalrows, int stattarget); |
| extern bytea *statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats); |
| extern MCVList *statext_mcv_deserialize(bytea *data); |
|
|
| extern MultiSortSupport multi_sort_init(int ndims); |
| extern void multi_sort_add_dimension(MultiSortSupport mss, int sortdim, |
| Oid oper, Oid collation); |
| extern int multi_sort_compare(const void *a, const void *b, void *arg); |
| extern int multi_sort_compare_dim(int dim, const SortItem *a, |
| const SortItem *b, MultiSortSupport mss); |
| extern int multi_sort_compare_dims(int start, int end, const SortItem *a, |
| const SortItem *b, MultiSortSupport mss); |
| extern int compare_scalars_simple(const void *a, const void *b, void *arg); |
| extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); |
|
|
| extern AttrNumber *build_attnums_array(Bitmapset *attrs, int nexprs, int *numattrs); |
|
|
| extern SortItem *build_sorted_items(StatsBuildData *data, int *nitems, |
| MultiSortSupport mss, |
| int numattrs, AttrNumber *attnums); |
|
|
| extern bool examine_opclause_args(List *args, Node **exprp, |
| Const **cstp, bool *expronleftp); |
|
|
| extern Selectivity mcv_combine_selectivities(Selectivity simple_sel, |
| Selectivity mcv_sel, |
| Selectivity mcv_basesel, |
| Selectivity mcv_totalsel); |
|
|
| extern Selectivity mcv_clauselist_selectivity(PlannerInfo *root, |
| StatisticExtInfo *stat, |
| List *clauses, |
| int varRelid, |
| JoinType jointype, |
| SpecialJoinInfo *sjinfo, |
| RelOptInfo *rel, |
| Selectivity *basesel, |
| Selectivity *totalsel); |
|
|
| extern Selectivity mcv_clause_selectivity_or(PlannerInfo *root, |
| StatisticExtInfo *stat, |
| MCVList *mcv, |
| Node *clause, |
| bool **or_matches, |
| Selectivity *basesel, |
| Selectivity *overlap_mcvsel, |
| Selectivity *overlap_basesel, |
| Selectivity *totalsel); |
|
|
| #endif |
|
|