Summary
The view pg_stats_ext provides access to information about each extended statistics object in the database, combining information stored in the pg_statistic_ext and pg_statistic_ext_data catalogs. This view allows access only to rows of pg_statistic_ext and pg_statistic_ext_data that correspond to tables the user owns, and therefore it is safe to allow public read access to this view.
(Description quoted from the official PostgreSQL documentation.)
Columns
The pg_stats_ext system view exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):
schemanamenamereferencespg_namespace.nspname
Name of schema containing tabletablenamenamereferencespg_class.relname
Name of tabletableidoidreferencespg_class.oid
OID of tablestatistics_schemanamenamereferencespg_namespace.nspname
Name of schema containing extended statistics objectstatistics_namenamereferencespg_statistic_ext.stxname
Name of extended statistics objectstatistics_idoidreferencespg_statistic_ext.oid
OID of extended statistics objectstatistics_ownernamereferencespg_authid.rolname
Owner of the extended statistics objectattnamesname[]referencespg_attribute.attname
Names of the columns included in the extended statistics objectexprstext[]
Expressions included in the extended statistics objectkindschar[]
Types of extended statistics object enabled for this tuple/">recordinheritedboolreferencespg_statistic_ext_data.stxdinherit
If true, the stats include values from child tables, not just the values in the specified relationn_distinctpg_ndistinct
N-distinct counts for combinations of column values. If greater than zero, the estimated number of distinct values in the combination. If less than zero, the negative of the number of distinct values divided by the number of rows. (The negated form is used when ANALYZE believes that the number of distinct values is likely to increase as the table grows; the positive form is used when the column seems to have a fixed number of possible values.) For example, -1 indicates a unique combination of columns in which the number of distinct combinations is the same as the number of rows.dependenciespg_dependencies
Functional dependency statisticsmost_common_valstext[]
A list of the most common combinations of values in the columns. (Null if no combinations seem to be more common than any others.)most_common_val_nullsbool[]
A list of NULL flags for the most common combinations of values. (Null when most_common_vals is.)most_common_freqsfloat8[]
A list of the frequencies of the most common combinations, i.e., number of occurrences of each divided by total number of rows. (Null when most_common_vals is.)most_common_base_freqsfloat8[]
A list of the base frequencies of the most common combinations, i.e., product of per-value frequencies. (Null when most_common_vals is.)
Related catalogs
This object references the following other system catalogs:
schemaname→pg_namespacetablename→pg_classstatistics_name→pg_statistic_extstatistics_owner→pg_authidattnames→pg_attributeinherited→pg_statistic_ext_data
Version applicability
Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.
Related & references
Reference: PostgreSQL documentation — pg_stats_ext.