Add support for multivariate MCV lists

Tomas Vondra <tomas.vondra@postgresql.org>

Commit: 7300a699502fe5432b05fbc75baca534b080bebb
Author: Tomas Vondra <tomas.vondra@postgresql.org>
Date: 2019-03-27T17:32:18Z
Releases: 12.0
Add support for multivariate MCV lists

Introduce a third extended statistic type, supported by the CREATE
STATISTICS command - MCV lists, a generalization of the statistic
already built and used for individual columns.

Compared to the already supported types (n-distinct coefficients and
functional dependencies), MCV lists are more complex, include column
values and allow estimation of much wider range of common clauses
(equality and inequality conditions, IS NULL, IS NOT NULL etc.).
Similarly to the other types, a new pseudo-type (pg_mcv_list) is used.

Author: Tomas Vondra
Reviewed-by: Dean Rasheed, David Rowley, Mark Dilger, Alvaro Herrera
Discussion: https://postgr.es/m/dfdac334-9cf2-2597-fb27-f0fb3753f435@2ndquadrant.com

Files

PathChange+/−
doc/src/sgml/catalogs.sgml modified +12 −1
doc/src/sgml/func.sgml modified +82 −0
doc/src/sgml/perform.sgml modified +66 −0
doc/src/sgml/planstats.sgml modified +114 −2
doc/src/sgml/ref/create_statistics.sgml modified +33 −2
src/backend/commands/statscmds.c modified +71 −11
src/backend/nodes/bitmapset.c modified +44 −0
src/backend/optimizer/path/clausesel.c modified +67 −42
src/backend/optimizer/util/plancat.c modified +12 −0
src/backend/parser/parse_utilcmd.c modified +2 −0
src/backend/statistics/dependencies.c modified +41 −59
src/backend/statistics/extended_stats.c modified +622 −5
src/backend/statistics/Makefile modified +1 −1
src/backend/statistics/mcv.c added +1695 −0
src/backend/statistics/README modified +4 −0
src/backend/statistics/README.mcv added +100 −0
src/backend/utils/adt/ruleutils.c modified +21 −3
src/bin/psql/describe.c modified +8 −1
src/bin/psql/tab-complete.c modified +1 −1
src/include/catalog/pg_cast.dat modified +6 −0
src/include/catalog/pg_proc.dat modified +24 −0
src/include/catalog/pg_statistic_ext.h modified +2 −0
src/include/catalog/pg_type.dat modified +7 −0
src/include/nodes/bitmapset.h modified +1 −0
src/include/optimizer/optimizer.h modified +6 −0
src/include/statistics/extended_stats_internal.h modified +40 −0
src/include/statistics/statistics.h modified +40 −0
src/test/regress/expected/create_table_like.out modified +1 −1
src/test/regress/expected/opr_sanity.out modified +2 −1
src/test/regress/expected/stats_ext.out modified +284 −3
src/test/regress/expected/type_sanity.out modified +2 −1
src/test/regress/sql/stats_ext.sql modified +186 −0

Documentation touched

Discussion