From bfd1ffa948e676f0587239a36e71f15690ef2cde Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 20 Sep 2006 19:50:21 +0000 Subject: Change patternsel (LIKE/regex selectivity estimation) so that if there is a large enough histogram, it will use the number of matches in the histogram to derive a selectivity estimate, rather than the admittedly pretty bogus heuristics involving examining the pattern contents. I set 'large enough' at 100, but perhaps we should change that later. Also apply the same technique in contrib/ltree's <@ and @> estimator. Per discussion with Stefan Kaltenbrunner and Matteo Beccati. --- src/include/utils/selfuncs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h index 065e9a5e221..aea2501ca39 100644 --- a/src/include/utils/selfuncs.h +++ b/src/include/utils/selfuncs.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.34 2006/07/01 22:07:23 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.35 2006/09/20 19:50:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -110,6 +110,9 @@ extern double get_variable_numdistinct(VariableStatData *vardata); extern double mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Datum constval, bool varonleft, double *sumcommonp); +extern double histogram_selectivity(VariableStatData *vardata, FmgrInfo *opproc, + Datum constval, bool varonleft, + int min_hist_size, int n_skip); extern Pattern_Prefix_Status pattern_fixed_prefix(Const *patt, Pattern_Type ptype, -- cgit v1.2.3