SYSTEM VIEW系统视图
pg_stats
规划器统计信息
系统视图 引入 9.0(基线) 现存至 20 devel 3 次结构变更
版本轨迹
相对 PostgreSQL 17 无变化。
视图pg_stats提供对存储在pg_statistic目录中信息的访问。 此视图仅允许访问用户具有读取权限的表对应的pg_statistic行, 因此可以安全地允许对此视图进行公共读取访问。
pg_stats也旨在以比底层目录更易读的格式呈现信息— 但其模式必须在为pg_statistic定义新的槽类型时进行扩展。
字段
PostgreSQL 18 的 17 个字段,按定义顺序排列。说明默认用本站手册的译文,没有译文的按英文原文显示。
| 字段 | 类型 | 说明 |
|---|---|---|
schemaname
|
name
pg_namespace.nspname
|
包含表的模式名称 |
tablename
|
name
pg_class.relname
|
表的名称 |
attname
|
name
pg_attribute.attname
|
被此行描述的列名 |
inherited
|
boolean
|
如果为true,则此行包括来自子表的值,而不仅仅是指定表中的值 |
null_frac
|
real
|
列项中为空的比例 |
avg_width
|
integer
|
列的条目的平均字节宽度 |
n_distinct
|
real
|
如果大于零,表示列中可区分值的估计个数。如果小于零,是可区分值个数除以行数的负值(当ANALYZE认为可区分值的数量会随着表增长而增加时采用负值的形式,而如果认为列具有固定数量的可选值时采用正值的形式)。 例如,-1表示一个唯一列,即其中可区分值的个数等于行数。 |
most_common_vals
|
anyarray
|
列中高频值的一个列表(如果没有任何一个值看起来比其他值更常用,此列为空) |
most_common_freqs
|
real[]
|
高频值的频率列表,即每一个高频值的出现次数除以总行数(如果most_common_vals为空,则此列为空) |
histogram_bounds
|
anyarray
|
将列值划分成大小接近的组的值列表。如果存在most_common_vals,其中的值会被直方图计算所忽略(如果列类型没有一个<操作符或者most_common_vals等于整个值集合,则此列为空) |
correlation
|
real
|
物理行顺序和列值逻辑顺序之间的统计关联。其范围从-1到+1。当值接近-1或+1时,在列上的一个索引扫描被认为比值接近0时的代价更低,因为这种情况减少了对磁盘的随机访问(如果列数据类型不具有一个<操作符,则此列为空) |
most_common_elems
|
anyarray
|
在列值中,最经常出现的非空元素列表(对标量类型为空) |
most_common_elem_freqs
|
real[]
|
最常用元素值的频度列表,即含有至少一个给定值实例的行的分数。 在每个元素的频度之后有二至三个附加值,它们是每个元素频度的最小和最大值,以及可选的空元素的频度(如果most_common_elems为空,则此列为空) |
elem_count_histogram
|
real[]
|
在列值中可区分非空元素值计数的一个直方图,后面跟随可区分非空元素的平均数(对于标量类型为空) |
range_length_histogram
|
anyarray
|
范围类型列中非空且非 NULL 的范围值长度直方图。(对非范围类型为空。) 该直方图使用范围函数 subtype_diff 计算,而不考虑范围边界是否包含端点。 |
range_empty_frac
|
real
|
列项中值为空范围的比例。(对非范围类型为空。) |
range_bounds_histogram
|
anyarray
|
非空且非 NULL 的范围值下界和上界的直方图。(对非范围类型为空。) 这两个直方图表示为单个数组列,其中下半部分表示下界的直方图,上半部分表示上界的直方图。 |
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的字段表。
-
PostgreSQL 19 ← 18 结构变更
tableidattnum -
PostgreSQL 17 ← 16 结构变更
range_length_histogramrange_empty_fracrange_bounds_histogram -
PostgreSQL 15 ← 14 仅描述更新
1 处描述更新
inheritedIf true, this row includes inheritance child columns, not just the values in the specified table If true, this row includes values from child tables, not just the values in the specified table
-
PostgreSQL 14 ← 13 仅描述更新
1 处描述更新
attnameName of the column described by this row Name of column described by this row
-
PostgreSQL 9.2 ← 9.1 结构变更
most_common_elemsmost_common_elem_freqselem_count_histogram2 处描述更新
most_common_freqsA list of the frequencies of the most common values or elements, i.e., number of occurrences of each divided by total number of rows. (Null when most_common_vals is.) For some data types such as tsvector, it can also store some additional information, making it longer than the most_common_vals array. 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.)most_common_valsA list of the most common values in the column. (Null if no values seem to be more common than any others.) For some data types such as tsvector, this is a list of the most common element values rather than values of the type itself. A list of the most common values in the column. (Null if no values seem to be more common than any others.)
字段矩阵
每个字段在 18 个收录版本里的存在情况;方格指向该版的字段表。「有变」指类型、可空、隐式或数组维数与上一版不同。
存在 有变 已移除 不存在
| 字段 | 9.0 | 9.1 | 9.2 | 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
schemaname |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
tablename |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
attname |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
inherited |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
null_frac |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
avg_width |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
n_distinct |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
most_common_vals |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
most_common_freqs |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
histogram_bounds |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
correlation |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
most_common_elems |
不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
most_common_elem_freqs |
不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
elem_count_histogram |
不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
range_length_histogram |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 |
range_empty_frac |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 |
range_bounds_histogram |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 |
tableid |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 |
attnum |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 |
同类关系
| 关系 | 引入 | 字段 | 版本变动 | 最近变更 |
|---|---|---|---|---|
pg_aios |
18 | 15 | — | |
| 正在使用的异步 I/O 句柄 | 现存 | |||
pg_available_extension_versions |
9.1 | 10 | 192 次 | |
| 扩展的可用版本 | 现存 | |||
pg_available_extensions |
9.1 | 5 | 191 次 | |
| 可用的扩展 | 现存 | |||
pg_backend_memory_contexts |
14 | 10 | 181 次 | |
| 后端内存上下文 | 现存 | |||
pg_config |
9.6 | 2 | — | |
| 编译时配置参数 | 现存 | |||
pg_cursors |
9.0基线 | 6 | — | |
| 打开的游标 | 现存 | |||
pg_dsm_registry_allocations |
19 | 3 | — | |
| DSM 注册表跟踪的共享内存分配 | 现存 | |||
pg_file_settings |
9.5 | 7 | — | |
| 配置文件内容摘要 | 现存 | |||
pg_group |
9.0基线 | 3 | — | |
| 数据库用户组 | 现存 | |||
pg_hba_file_rules |
10 | 11 | 161 次 | |
| 客户端认证配置文件内容的摘要 | 现存 | |||
pg_ident_file_mappings |
15 | 7 | 161 次 | |
| 客户端用户名映射配置文件内容摘要 | 现存 | |||
pg_indexes |
9.0基线 | 5 | — | |
| 索引 | 现存 | |||
pg_locks |
9.0基线 | 16 | 142 次 | |
| 当前持有或等待的锁 | 现存 | |||
pg_matviews |
9.3 | 7 | — | |
| 物化视图 | 现存 | |||
pg_policies |
9.5 | 8 | 101 次 | |
| 策略 | 现存 | |||
pg_prepared_statements |
9.0基线 | 8 | 162 次 | |
| 预备语句 | 现存 | |||
pg_prepared_xacts |
9.0基线 | 5 | — | |
| 预备事务 | 现存 | |||
pg_publication_sequences |
19 | 3 | — | |
| 发布及其关联序列的信息 | 现存 | |||
pg_publication_tables |
10 | 5 | 151 次 | |
| 发布及其关联表的信息 | 现存 | |||
pg_replication_origin_status |
9.5 | 4 | — | |
| 有关复制源的信息,包括复制进度 | 现存 | |||
pg_replication_slots |
9.4 | 22 | 199 次 | |
| 复制槽信息 | 现存 | |||
pg_roles |
9.0基线 | 13 | 9.52 次 | |
| 数据库角色 | 现存 | |||
pg_rules |
9.0基线 | 4 | — | |
| 规则 | 现存 | |||
pg_seclabels |
9.1 | 8 | — | |
| 安全标签 | 现存 | |||
pg_sequences |
10 | 11 | — | |
| 序列 | 现存 | |||
pg_settings |
9.0基线 | 17 | 9.51 次 | |
| 参数设置 | 现存 | |||
pg_shadow |
9.0基线 | 9 | 123 次 | |
| 数据库用户 | 现存 | |||
pg_shmem_allocations |
13 | 4 | — | |
| 共享内存分配 | 现存 | |||
pg_shmem_allocations_numa |
18 | 3 | — | |
| 共享内存分配的 NUMA 节点映射 | 现存 | |||
pg_stats |
9.0基线 | 19 | 193 次 | |
| 规划器统计信息 | 现存 | |||
pg_stats_ext |
12 | 17 | 193 次 | |
| 扩展规划器统计信息 | 现存 | |||
pg_stats_ext_exprs |
14 | 22 | 192 次 | |
| 表达式的扩展规划器统计信息 | 现存 | |||
pg_tables |
9.0基线 | 8 | 9.51 次 | |
| 表 | 现存 | |||
pg_timezone_abbrevs |
9.0基线 | 3 | — | |
| 时区简写 | 现存 | |||
pg_timezone_names |
9.0基线 | 4 | — | |
| 时区名称 | 现存 | |||
pg_user |
9.0基线 | 9 | 123 次 | |
| 数据库用户 | 现存 | |||
pg_user_mappings |
9.0基线 | 6 | — | |
| 用户映射 | 现存 | |||
pg_views |
9.0基线 | 4 | — | |
| 视图 | 现存 | |||
pg_wait_events |
17 | 3 | — | |
| 等待事件 | 现存 | |||