选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

受支持版本: 当前版本 (18) / 17 / 16 / 15 / 14
测试与开发版本: 19 / devel
不受支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0
历史版本PostgreSQL 9.1 已于 2016 年 10 月结束社区维护,本页译文保留供仍在使用旧版本的读者参考。新系统请看当前版本

45.64. pg_stats #

视图pg_stats提供对存储在pg_statistic目录中信息的访问。 此视图仅允许访问用户具有读取权限的表对应的pg_statistic行, 因此可以安全地允许对此视图进行公共读取访问。

pg_stats也旨在以比底层目录更易读的格式呈现信息— 但其模式必须在为pg_statistic定义新的槽类型时进行扩展。

表 45.65. pg_stats

Name Type References Description
schemaname name pg_namespace.nspname Name of schema containing table
tablename name pg_class.relname Name of table
attname name pg_attribute.attname Name of the column described by this row
inherited bool   If true, this row includes inheritance child columns, not just the values in the specified table
null_frac real   Fraction of column entries that are null
avg_width integer   Average width in bytes of column's entries
n_distinct real   If greater than zero, the estimated number of distinct values in the column. 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 column in which the number of distinct values is the same as the number of rows.
most_common_vals anyarray   A 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.
most_common_freqs real[]   A 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.
histogram_bounds anyarray   A list of values that divide the column's values into groups of approximately equal population. The values in most_common_vals, if present, are omitted from this histogram calculation. (This column is null if the column data type does not have a < operator or if the most_common_vals list accounts for the entire population.)
correlation real   Statistical correlation between physical row ordering and logical ordering of the column values. This ranges from -1 to +1. When the value is near -1 or +1, an index scan on the column will be estimated to be cheaper than when it is near zero, due to reduction of random access to the disk. (This column is null if the column data type does not have a < operator.)

most_common_valshistogram_bounds 数组中的最大项数可以逐列地用 ALTER TABLE SET STATISTICS 命令设置,或者全局地通过设置 default_statistics_target 运行时参数来设置。

提交更正

译文有误、术语不当或页面显示问题,请到译文仓库 pgsty/pgdoc 报告译文问题。 英文原文本身的问题,请在当前版本的对应页面向上游反馈;上游不再修订已结束维护的版本。