summaryrefslogtreecommitdiff
path: root/src/include/utils/selfuncs.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-03-03 20:20:19 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-03-03 20:20:57 -0500
commit0e5e167aaea4ceb355a6e20eec96c4f7d05527ab (patch)
tree1b1b338461cba27a2d783db13b74d1b7b86b6681 /src/include/utils/selfuncs.h
parent34c978442c55dd13a3a8c6b90fd4380dad02f3da (diff)
downloadpostgresql-0e5e167aaea4ceb355a6e20eec96c4f7d05527ab.tar.gz
Collect and use element-frequency statistics for arrays.
This patch improves selectivity estimation for the array <@, &&, and @> (containment and overlaps) operators. It enables collection of statistics about individual array element values by ANALYZE, and introduces operator-specific estimators that use these stats. In addition, ScalarArrayOpExpr constructs of the forms "const = ANY/ALL (array_column)" and "const <> ANY/ALL (array_column)" are estimated by treating them as variants of the containment operators. Since we still collect scalar-style stats about the array values as a whole, the pg_stats view is expanded to show both these stats and the array-style stats in separate columns. This creates an incompatible change in how stats for tsvector columns are displayed in pg_stats: the stats about lexemes are now displayed in the array-related columns instead of the original scalar-related columns. There are a few loose ends here, notably that it'd be nice to be able to suppress either the scalar-style stats or the array-element stats for columns for which they're not useful. But the patch is in good enough shape to commit for wider testing. Alexander Korotkov, reviewed by Noah Misch and Nathan Boley
Diffstat (limited to 'src/include/utils/selfuncs.h')
-rw-r--r--src/include/utils/selfuncs.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
index bffc2d80ef..4529f27683 100644
--- a/src/include/utils/selfuncs.h
+++ b/src/include/utils/selfuncs.h
@@ -95,9 +95,6 @@ typedef enum
Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact
} Pattern_Prefix_Status;
-
-/* selfuncs.c */
-
/* Hooks for plugins to get control when we ask for stats */
typedef bool (*get_relation_stats_hook_type) (PlannerInfo *root,
RangeTblEntry *rte,
@@ -110,6 +107,8 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
VariableStatData *vardata);
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
+/* Functions in selfuncs.c */
+
extern void examine_variable(PlannerInfo *root, Node *node, int varRelid,
VariableStatData *vardata);
extern bool get_restriction_variable(PlannerInfo *root, List *args,
@@ -197,4 +196,13 @@ extern Datum gistcostestimate(PG_FUNCTION_ARGS);
extern Datum spgcostestimate(PG_FUNCTION_ARGS);
extern Datum gincostestimate(PG_FUNCTION_ARGS);
+/* Functions in array_selfuncs.c */
+
+extern Selectivity scalararraysel_containment(PlannerInfo *root,
+ Node *leftop, Node *rightop,
+ Oid elemtype, bool isEquality, bool useOr,
+ int varRelid);
+extern Datum arraycontsel(PG_FUNCTION_ARGS);
+extern Datum arraycontjoinsel(PG_FUNCTION_ARGS);
+
#endif /* SELFUNCS_H */