postgresql/contrib/hstore
Tom Lane 7d08ce286c Distinguish selectivity of < from <= and > from >=.
Historically, the selectivity functions have simply not distinguished
< from <=, or > from >=, arguing that the fraction of the population that
satisfies the "=" aspect can be considered to be vanishingly small, if the
comparison value isn't any of the most-common-values for the variable.
(If it is, the code path that executes the operator against each MCV will
take care of things properly.)  But that isn't really true unless we're
dealing with a continuum of variable values, and in practice we seldom are.
If "x = const" would estimate a nonzero number of rows for a given const
value, then it follows that we ought to estimate different numbers of rows
for "x < const" and "x <= const", even if the const is not one of the MCVs.
Handling this more honestly makes a significant difference in edge cases,
such as the estimate for a tight range (x BETWEEN y AND z where y and z
are close together).

Hence, split scalarltsel into scalarltsel/scalarlesel, and similarly
split scalargtsel into scalargtsel/scalargesel.  Adjust <= and >=
operator definitions to reference the new selectivity functions.
Improve the core ineq_histogram_selectivity() function to make a
correction for equality.  (Along the way, I learned quite a bit about
exactly why that function gives good answers, which I tried to memorialize
in improved comments.)

The corresponding join selectivity functions were, and remain, just stubs.
But I chose to split them similarly, to avoid confusion and to prevent the
need for doing this exercise again if someone ever makes them less stubby.

In passing, change ineq_histogram_selectivity's clamp for extreme
probability estimates so that it varies depending on the histogram
size, instead of being hardwired at 0.0001.  With the default histogram
size of 100 entries, you still get the old clamp value, but bigger
histograms should allow us to put more faith in edge values.

Tom Lane, reviewed by Aleksander Alekseev and Kuntal Ghosh

Discussion: https://postgr.es/m/12232.1499140410@sss.pgh.pa.us
2017-09-13 11:12:39 -04:00
..
data Add GIN support for pg_trgm. From Guillaume Smet <guillaume.smet@gmail.com> 2007-03-14 14:21:53 +00:00
expected Test all contrib-created operator classes with amvalidate. 2016-11-29 15:05:22 -05:00
sql Test all contrib-created operator classes with amvalidate. 2016-11-29 15:05:22 -05:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
hstore--1.0--1.1.sql Fix typo in update scripts for some contrib modules. 2013-07-19 04:13:01 +09:00
hstore--1.1--1.2.sql Fix whitespace issues found by git diff --check, add gitattributes 2013-11-10 14:48:29 -05:00
hstore--1.2--1.3.sql Introduce jsonb, a structured format for storing json. 2014-03-23 16:40:19 -04:00
hstore--1.3--1.4.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
hstore--1.4--1.5.sql Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
hstore--1.4.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
hstore--unpackaged--1.0.sql Fix typos in some error messages thrown by extension scripts when fed to psql. 2014-08-25 18:30:37 +02:00
hstore.control Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
hstore.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
hstore_compat.c Dodge a macro-name conflict with Perl. 2015-11-19 14:54:11 -05:00
hstore_gin.c Dodge a macro-name conflict with Perl. 2015-11-19 14:54:11 -05:00
hstore_gist.c Dodge a macro-name conflict with Perl. 2015-11-19 14:54:11 -05:00
hstore_io.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
hstore_op.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00