pg_statistic 是一个系统目录表,存储有关表列和索引表达式内容统计数据。
pg_statistic 在所有 PostgreSQL 版本中都存在。
按 PostgreSQL 版本定义
pg_statistic (PostgreSQL 19)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 18)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 17)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 16)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 15)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 14)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" PRIMARY KEY, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 13)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 12)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stacoll1 | oid | | not null |
stacoll2 | oid | | not null |
stacoll3 | oid | | not null |
stacoll4 | oid | | not null |
stacoll5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 11)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 10)
Table "pg_catalog.pg_statistic"
Column | Type | Collation | Nullable | Default
-------------+----------+-----------+----------+---------
starelid | oid | | not null |
staattnum | smallint | | not null |
stainherit | boolean | | not null |
stanullfrac | real | | not null |
stawidth | integer | | not null |
stadistinct | real | | not null |
stakind1 | smallint | | not null |
stakind2 | smallint | | not null |
stakind3 | smallint | | not null |
stakind4 | smallint | | not null |
stakind5 | smallint | | not null |
staop1 | oid | | not null |
staop2 | oid | | not null |
staop3 | oid | | not null |
staop4 | oid | | not null |
staop5 | oid | | not null |
stanumbers1 | real[] | | |
stanumbers2 | real[] | | |
stanumbers3 | real[] | | |
stanumbers4 | real[] | | |
stanumbers5 | real[] | | |
stavalues1 | anyarray | | |
stavalues2 | anyarray | | |
stavalues3 | anyarray | | |
stavalues4 | anyarray | | |
stavalues5 | anyarray | | |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.6)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
stakind5 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
staop5 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stanumbers5 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
stavalues5 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.5)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
stakind5 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
staop5 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stanumbers5 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
stavalues5 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.4)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
stakind5 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
staop5 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stanumbers5 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
stavalues5 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.3)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
stakind5 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
staop5 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stanumbers5 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
stavalues5 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.2)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
stakind5 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
staop5 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stanumbers5 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
stavalues5 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.1)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 9.0)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stainherit | boolean | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
Indexes:
"pg_statistic_relid_att_inh_index" UNIQUE, btree (starelid, staattnum, stainherit)
文档: pg_statistic
pg_statistic (PostgreSQL 8.4)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
Indexes:
"pg_statistic_relid_att_index" UNIQUE, btree (starelid, staattnum)
文档: pg_statistic
pg_statistic (PostgreSQL 8.3)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
Indexes:
"pg_statistic_relid_att_index" UNIQUE, btree (starelid, staattnum)
文档: pg_statistic
pg_statistic (PostgreSQL 8.2)
Table "pg_catalog.pg_statistic"
Column | Type | Modifiers
-------------+----------+-----------
starelid | oid | not null
staattnum | smallint | not null
stanullfrac | real | not null
stawidth | integer | not null
stadistinct | real | not null
stakind1 | smallint | not null
stakind2 | smallint | not null
stakind3 | smallint | not null
stakind4 | smallint | not null
staop1 | oid | not null
staop2 | oid | not null
staop3 | oid | not null
staop4 | oid | not null
stanumbers1 | real[] |
stanumbers2 | real[] |
stanumbers3 | real[] |
stanumbers4 | real[] |
stavalues1 | anyarray |
stavalues2 | anyarray |
stavalues3 | anyarray |
stavalues4 | anyarray |
Indexes:
"pg_statistic_relid_att_index" UNIQUE, btree (starelid, staattnum)
文档: pg_statistic
变更历史
- PostgreSQL 12
- 添加了以下列(提交 5e092800)
stacoll1stacoll2stacoll3stacoll4stacoll5
- 添加了以下列(提交 5e092800)
- PostgreSQL 9.2
- 添加了以下列(提交 0e5e167a)
stakind5staop5stanumbers5stavalues5
- 添加了以下列(提交 0e5e167a)
- PostgreSQL 9.0
- 添加了列
stainherit(提交 649b5ec7)
- 添加了列
- PostgreSQL 7.2
- 主要重构(提交 f905d65e)
参考资料
- PostgreSQL 文档: pg_statistic
