Обсуждение: pgsql: Collect and use histograms of lower and upper bounds for range t

Поиск
Список
Период
Сортировка

pgsql: Collect and use histograms of lower and upper bounds for range t

От
Heikki Linnakangas
Дата:
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/918eee0c497c88260a2e107318843c9b1947bc6f

Modified Files
--------------
src/backend/utils/adt/Makefile                |    3 +-
src/backend/utils/adt/rangetypes.c            |   17 -
src/backend/utils/adt/rangetypes_selfuncs.c   |  599 +++++++++++++++++++++++++
src/backend/utils/adt/rangetypes_typanalyze.c |  232 ++++++++++
src/include/catalog/catversion.h              |    2 +-
src/include/catalog/pg_operator.h             |   39 ++-
src/include/catalog/pg_proc.h                 |    2 +
src/include/catalog/pg_statistic.h            |   18 +
src/include/utils/rangetypes.h                |    1 +
9 files changed, 881 insertions(+), 32 deletions(-)