跳转到主要内容
← 目录图谱 / pg_stats_ext

SYSTEM VIEW · 系统视图

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.

首次收录 PG 12最近收录 PG 19当前字段 15

已与 PostgreSQL 18.6 实例逐字段核对 · 原始实测记录 ↗

字段结构 PostgreSQL 18

pg_stats_ext
字段 / COLUMN类型 / TYPE说明 / DESCRIPTION
schemaname name Name of schema containing table引用:pg_namespace.nspname
tablename name Name of table引用:pg_class.relname
statistics_schemaname name Name of schema containing extended statistics object引用:pg_namespace.nspname
statistics_name name Name of extended statistics object引用:pg_statistic_ext.stxname
statistics_owner name Owner of the extended statistics object引用:pg_authid.rolname
attnames name[] Names of the columns included in the extended statistics object引用:pg_attribute.attname
exprs text[] Expressions included in the extended statistics object
kinds "char"[]文档原写法:char[] Types of extended statistics object enabled for this record
inherited boolean文档原写法:bool If true, the stats include values from child tables, not just the values in the specified relation引用:pg_statistic_ext_data.stxdinherit
n_distinct pg_ndistinct N-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.
dependencies pg_dependencies Functional dependency statistics
most_common_vals text[] A 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_nulls boolean[]文档原写法:bool[] A list of NULL flags for the most common combinations of values. (Null when most_common_vals is.)
most_common_freqs double precision[]文档原写法:float8[] A 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_freqs double precision[]文档原写法:float8[] A list of the base frequencies of the most common combinations, i.e., product of per-value frequencies. (Null when most_common_vals is.)

标记“隐式列”的字段不包含在 SELECT * 中;部分早期统计视图由同版本源码补全,额外来源会显示在字段说明中。

字段演化矩阵

悬停查看字段类型
存在新增 / 类型或属性变化移除
字段 / COLUMN9.09.19.29.39.49.59.610111213141516171819
schemaname
tablename
statistics_schemaname
statistics_name
statistics_owner
attnames
kinds
n_distinct
dependencies
most_common_vals
most_common_val_nulls
most_common_freqs
most_common_base_freqs
exprs
inherited
tableid
statistics_id

9.0 是收录基线;基线中已存在的字段不标记为新增。矩阵按字段名称对齐,重命名显示为旧字段移除与新字段新增。

演化时间线

相邻大版本的变化

PostgreSQL 19 ← 18

+ tableid+ statistics_id

PostgreSQL 15 ← 14

+ inherited

PostgreSQL 14 ← 13

+ exprs5 处字段说明更新目录说明更新

PostgreSQL 12 ← 11新增目录

+ schemaname+ tablename+ statistics_schemaname+ statistics_name+ statistics_owner+ attnames+ kinds+ n_distinct+ dependencies+ most_common_vals+ most_common_val_nulls+ most_common_freqs+ most_common_base_freqs

比较任意两个版本

选择两个版本,查看字段的新增、移除与类型变化。交互比较需要 JavaScript;演化时间线可直接阅读。