pg_stats_ext_exprs

A system view containing information about all expressions included in extended statistics objects
This entry relates to a PostgreSQL feature which is part of PostgreSQL 14, due to be released in late 2021.

pg_stats_ext_exprs is a system catalog view storing information about extended statistics objects which include expressions.

pg_stats_ext_exprs was added in PostgreSQL 14.

Definition by PostgreSQL version

pg_stats_ext_exprs (PostgreSQL 14)

                View "pg_catalog.pg_stats_ext_exprs"
         Column         |   Type   | Collation | Nullable | Default 
------------------------+----------+-----------+----------+---------
 schemaname             | name     |           |          | 
 tablename              | name     |           |          | 
 statistics_schemaname  | name     |           |          | 
 statistics_name        | name     |           |          | 
 statistics_owner       | name     |           |          | 
 expr                   | text     |           |          | 
 null_frac              | real     |           |          | 
 avg_width              | integer  |           |          | 
 n_distinct             | real     |           |          | 
 most_common_vals       | anyarray |           |          | 
 most_common_freqs      | real[]   |           |          | 
 histogram_bounds       | anyarray |           |          | 
 correlation            | real     |           |          | 
 most_common_elems      | anyarray |           |          | 
 most_common_elem_freqs | real[]   |           |          | 
 elem_count_histogram   | real[]   |           |          |
    

Documentation: pg_stats_ext_exprs

Change history

Examples

Basic usage example for pg_stats_ext_exprs:

postgres=# CREATE TABLE foo (id int);
CREATE TABLE

postgres=# INSERT INTO foo values(generate_series(1,10000));
INSERT 0 10000

postgres=# CREATE STATISTICS s ON mod(id,5) FROM foo;
CREATE STATISTICS

postgres=# SELECT * FROM pg_stats_ext_exprs;
-[ RECORD 1 ]----------+----------------------
schemaname             | public
tablename              | foo
statistics_schemaname  | public
statistics_name        | s
statistics_owner       | postgres
expr                   | mod(id, 5)
null_frac              | 0
avg_width              | 4
n_distinct             | 5
most_common_vals       | {0,1,2,3,4}
most_common_freqs      | {0.2,0.2,0.2,0.2,0.2}
histogram_bounds       | 
correlation            | 0.19999996
most_common_elems      | 
most_common_elem_freqs | 
elem_count_histogram   | 

postgres=# ANALYZE foo;
ANALYZE

Categories

System catalogue

See also

pg_stats_ext, pg_stats