pg_stats_ext_exprs
是一个存储有关包含表达式的扩展统计对象的信息的系统目录视图。
pg_stats_ext_exprs
添加于PostgreSQL 14。
按 PostgreSQL 版本定义
pg_stats_ext_exprs (PostgreSQL 17)
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 | | | inherited | boolean | | | 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[] | | |
pg_stats_ext_exprs (PostgreSQL 16)
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 | | | inherited | boolean | | | 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[] | | |
pg_stats_ext_exprs (PostgreSQL 15)
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 | | | inherited | boolean | | | 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[] | | |
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[] | | |
更改历史记录
- PostgreSQL 15
- 添加了列
inherited
(提交 269b532a)
- 添加了列
- PostgreSQL 14
- 添加 (提交 a4d75c86)
示例
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=# ANALYZE foo; ANALYZE 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 |
参考文献
- PostgreSQL 文档: pg_stats_ext_exprs