↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / System Catalogs

pg_stats_ext

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. pg_stats_ext is also designed to present the information in a more readable format than the underlying catalogs — at the cost that its schema must be extended whenever new types of extended statistics are added to pg_statistic_ext.

English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

kind
view
lang
en
measured attributes
true
metadata release
18.6
runtime columns
schemaname, tablename, statistics_schemaname, statistics_name, statistics_owner, attnames, exprs, kinds, inherited, n_distinct, dependencies, most_common_vals, most_common_val_nulls, most_common_freqs, most_common_base_freqs
runtime verified
false
source
english-manual

Definition PG 18

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. pg_stats_ext is also designed to present the information in a more readable format than the underlying catalogs — at the cost that its schema must be extended whenever new types of extended statistics are added to pg_statistic_ext.

Catalog columns

ColumnTypeNullabilityDescription
schemanamenameNullableName of schema containing table
tablenamenameNullableName of table
statistics_schemanamenameNullableName of schema containing extended statistics object
statistics_namenameNullableName of extended statistics object
statistics_ownernameNullableOwner of the extended statistics object
attnamesname[]NullableNames of the columns included in the extended statistics object
exprstext[]NullableExpressions included in the extended statistics object
kindschar[]NullableTypes of extended statistics object enabled for this record
inheritedboolNullableIf true, the stats include values from child tables, not just the values in the specified relation
n_distinctpg_ndistinctNullableN-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_dependenciesNullableFunctional dependency statistics
most_common_valstext[]NullableA 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[]NullableA list of NULL flags for the most common combinations of values. (Null when most_common_vals is.)
most_common_freqsfloat8[]NullableA 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[]NullableA list of the base frequencies of the most common combinations, i.e., product of per-value frequencies. (Null when most_common_vals is.)

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · catalog-bilingual-repair:1c6f39cae8a640486954cca69fb80020e22f46d23dc0ac7df350bcdbaff1915a

Text language: en · catalog-bilingual-repair:1c6f39cae8a640486954cca69fb80020e22f46d23dc0ac7df350bcdbaff1915a