Summary
The view pg_stats_ext_exprs provides access to information about all expressions included in extended statistics objects, 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_exprs 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 table the statistics object is defined ontableidoidreferencespg_class.oid
OID of table the statistics object is defined onstatistics_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 objectexprtext
Expression included in the extended statistics objectinheritedboolreferencespg_statistic_ext_data.stxdinherit
If true, the stats include values from child tables, not just the values in the specified relationnull_fracfloat4
Fraction of expression entries that are nullavg_widthint4
Average width in bytes of expression’s entriesn_distinctfloat4
If greater than zero, the estimated number of distinct values in the expression. 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 expression seems to have a fixed number of possible values.) For example, -1 indicates a unique expression in which the number of distinct values is the same as the number of rows.most_common_valsanyarray
A list of the most common values in the expression. (Null if no values seem to be more common than any others.)most_common_freqsfloat4[]
A list of the frequencies of the most common values, i.e., number of occurrences of each divided by total number of rows. (Null when most_common_vals is.)histogram_boundsanyarray
A list of values that divide the expression’s values into groups of approximately equal population. The values in most_common_vals, if present, are omitted from this histogram calculation. (This expression is null if the expression data type does not have a < operator or if the most_common_vals list accounts for the entire population.)correlationfloat4
Statistical correlation between physical row ordering and logical ordering of the expression values. This ranges from -1 to +1. When the value is near -1 or +1, an index scan on the expression will be estimated to be cheaper than when it is near zero, due to reduction of random access to the disk. (This expression is null if the expression’s data type does not have a < operator.)most_common_elemsanyarray
A list of non-null element values most often appearing within values of the expression. (Null for scalar types.)most_common_elem_freqsfloat4[]
A list of the frequencies of the most common element values, i.e., the fraction of rows containing at least one instance of the given value. Two or three additional values follow the per-element frequencies; these are the minimum and maximum of the preceding per-element frequencies, and optionally the frequency of null elements. (Null when most_common_elems is.)elem_count_histogramfloat4[]
A histogram of the counts of distinct non-null element values within the values of the expression, followed by the average number of distinct non-null elements. (Null for scalar types.)range_length_histogramanyarray
A histogram of the lengths of non-empty and non-null range values of an expression. (Null for non-range types.) This histogram is calculated using the subtype_diff range function regardless of whether range bounds are inclusive.range_empty_fracfloat4
Fraction of expression entries whose values are empty ranges. (Null for non-range types.)range_bounds_histogramanyarray
A histogram of lower and upper bounds of non-empty and non-null range values. (Null for non-range types.) These two histograms are represented as a single array of ranges, whose lower bounds represent the histogram of lower bounds, and upper bounds represent the histogram of upper bounds.
Related catalogs
This object references the following other system catalogs:
schemaname→pg_namespacetablename→pg_classstatistics_name→pg_statistic_extstatistics_owner→pg_authidinherited→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_exprs.