]> granicus.if.org Git - postgresql/commit
Collect and use histograms of lower and upper bounds for range types.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 27 Aug 2012 12:48:46 +0000 (15:48 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 27 Aug 2012 12:58:46 +0000 (15:58 +0300)
commit918eee0c497c88260a2e107318843c9b1947bc6f
treef2330fee96a1790dfd5070f0972998f271c078d4
parent6bb0b08fe65de32c5d43c0f7c76bd34801ce5056
Collect and use histograms of lower and upper bounds for range types.

This enables selectivity estimation of the <<, >>, &<, &> and && operators,
as well as the normal inequality operators: <, <=, >=, >. "range @> element"
is also supported, but the range-variant @> and <@ operators are not,
because they cannot be sensibly estimated with lower and upper bound
histograms alone. We would need to make some assumption about the lengths of
the ranges for that. Alexander's patch included a separate histogram of
lengths for that, but I left that out of the patch for simplicity. Hopefully
that will be added as a followup patch.

The fraction of empty ranges is also calculated and used in estimation.

Alexander Korotkov, heavily modified by me.
src/backend/utils/adt/Makefile
src/backend/utils/adt/rangetypes.c
src/backend/utils/adt/rangetypes_selfuncs.c [new file with mode: 0644]
src/backend/utils/adt/rangetypes_typanalyze.c [new file with mode: 0644]
src/include/catalog/catversion.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_statistic.h
src/include/utils/rangetypes.h