Collect and use multi-column dependency stats

Simon Riggs <simon@2ndQuadrant.com>

Commit: 2686ee1b7ccfb9214064d4d2a98ea77382880306
Author: Simon Riggs <simon@2ndQuadrant.com>
Date: 2017-04-05T22:00:42Z
Releases: 10.0
Collect and use multi-column dependency stats

Follow on patch in the multi-variate statistics patch series.

CREATE STATISTICS s1 WITH (dependencies) ON (a, b) FROM t;
ANALYZE;
will collect dependency stats on (a, b) and then use the measured
dependency in subsequent query planning.

Commit 7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b added
CREATE STATISTICS with n-distinct coefficients. These are now
specified using the mutually exclusive option WITH (ndistinct).

Author: Tomas Vondra, David Rowley
Reviewed-by: Kyotaro HORIGUCHI, Álvaro Herrera, Dean Rasheed, Robert Haas
and many other comments and contributions
Discussion: https://postgr.es/m/56f40b20-c464-fad2-ff39-06b668fac47c@2ndquadrant.com

Files

PathChange+/−
contrib/file_fdw/file_fdw.c modified +1 −0
contrib/postgres_fdw/postgres_fdw.c modified +4 −1
doc/src/sgml/catalogs.sgml modified +9 −0
doc/src/sgml/planstats.sgml modified +154 −0
doc/src/sgml/ref/create_statistics.sgml modified +39 −3
src/backend/catalog/system_views.sql modified +2 −1
src/backend/commands/statscmds.c modified +15 −2
src/backend/optimizer/path/clausesel.c modified +82 −31
src/backend/optimizer/path/costsize.c modified +16 −9
src/backend/optimizer/util/orclauses.c modified +2 −2
src/backend/optimizer/util/plancat.c modified +12 −0
src/backend/statistics/dependencies.c added +1079 −0
src/backend/statistics/extended_stats.c modified +101 −4
src/backend/statistics/Makefile modified +1 −1
src/backend/statistics/README modified +65 −3
src/backend/statistics/README.dependencies added +119 −0
src/backend/utils/adt/ruleutils.c modified +53 −1
src/backend/utils/adt/selfuncs.c modified +14 −6
src/bin/psql/describe.c modified +9 −3
src/include/catalog/pg_cast.h modified +4 −0
src/include/catalog/pg_proc.h modified +9 −0
src/include/catalog/pg_statistic_ext.h modified +5 −2
src/include/catalog/pg_type.h modified +4 −0
src/include/optimizer/cost.h modified +4 −2
src/include/statistics/extended_stats_internal.h modified +5 −0
src/include/statistics/statistics.h modified +44 −0
src/test/regress/expected/opr_sanity.out modified +2 −1
src/test/regress/expected/rules.out modified +2 −1
src/test/regress/expected/stats_ext.out modified +107 −3
src/test/regress/expected/type_sanity.out modified +4 −3
src/test/regress/sql/stats_ext.sql modified +68 −0

Documentation touched

Discussion