3
Advanced Statistics
Contains
Multivariate statistics (across multiple columns)
Expression Statistics
A database objectDatabase object created manually
resides in pg_statistic_ext and pg_statistic_ext_data
the pg_stats_ext and pg_stats_ext_exprs views
Once created, the statistics are automatically collected.
The base statistics automatically collected may not be sufficient for accurate
estimates of cardinality and selectivity.
PostgreSQL allows the database administrator to manually determine which
additional, extended statistics are required. You can collect statistics that
cover multiple columns (multivariate statistics) or statistics for arbitrary
expressions.
Keep in mind that base statistics are automatically collected for tables and
their columns, but not for indexes—except for expression indexes.
Therefore, an index built on multiple columns does not automatically result in
the generation of multivariate statistics.
Extended statistics can be created using the CREATE STATISTICS
command. Once the object is created, the corresponding statistics are
automatically collected in the background or via the ANALYZE command.
The collected information is stored in the tables pg_statistic_ext and
pg_statistic_ext_data; the statistics accessible to users are displayed in the
views pg_stats_ext and pg_stats_ext_exprs.