↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

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

百科 / 系统目录 / 系统目录表

SYSTEM CATALOG系统目录表

pg_index

索引的补充信息

系统目录表 引入 7.4(基线) 现存至 20 devel 9 次结构变更

关系 OID
2610
关系类型
r(普通表)
字段数
21
引入版本
7.4(收录基线)
版本状态
当前稳定版
结构变更
9 次

PostgreSQL 18 手册 官方文档 源码定义

版本轨迹

相对 PostgreSQL 17 无变化。

目录 pg_index 包含关于索引的部分信息。其他信息大部分在 pg_class 中。

字段

PostgreSQL 18.7 的 21 个字段,按定义顺序排列。说明默认用本站手册的译文,没有译文的按英文原文显示。

字段 类型 说明
indexrelid oidNOT NULL pg_class.oid 此索引的 pg_class 项的 OID
indrelid oidNOT NULL pg_class.oid 此索引所对应的基表的 pg_class 项的 OID
indnatts smallintNOT NULL 索引中的总列数(与 pg_class.relnatts 重复);此数目包括键属性和内含属性
indnkeyatts smallintNOT NULL 索引中键列的数量,不计内含列;内含列仅被存储,不参与索引语义
indisunique booleanNOT NULL 如为真,这是唯一索引
indnullsnotdistinct booleanNOT NULL 该值只用于唯一索引。如果为 false,则该唯一索引会将 null 值视为彼此不同(因此索引的某一列中可以包含多个 null 值,这是 PostgreSQL 的默认行为)。如果为 true,则会将 null 值视为相等(因此索引的某一列中只能包含一个 null 值)。
indisprimary booleanNOT NULL 如为真,表示索引为表的主键(如果此列为真,indisunique 也总是为真)
indisexclusion booleanNOT NULL 如为真,此索引支持一个排他约束
indimmediate booleanNOT NULL 如为真,唯一性检查在插入时立即被执行(如果 indisunique 为假,此列无关)
indisclustered booleanNOT NULL 如果为真,表示表最后以此索引进行了聚簇
indisvalid booleanNOT NULL 如果为真,此索引当前可用于查询。为假表示索引可能不完整:INSERT/UPDATE 操作仍必须修改该索引,但查询不能安全地使用它。如果它是唯一索引,其唯一性也无法保证。
indcheckxmin booleanNOT NULL 如果为真,查询必须等到此 pg_index 行的 xmin 低于这些查询的 TransactionXmin 事件视界后,才能使用该索引,因为表中可能有断裂的 HOT 链,其中包含这些查询可见的不兼容行
indisready booleanNOT NULL 如果为真,表示此索引当前可以用于插入。为假表示索引必须被 INSERT/UPDATE 操作忽略。
indislive booleanNOT NULL 如果为假,索引正处于被删除过程中,并且必须被所有处理忽略(包括 HOT 安全的决策)
indisreplident booleanNOT NULL 如果为真,此索引已通过 ALTER TABLE ... REPLICA IDENTITY USING INDEX ... 被选作“复制标识”
indkey int2vectorNOT NULL pg_attribute.attnum 这是一个包含 indnatts 个值的数组,指明此索引为哪些表列建立索引。例如,值 1 3 表示表的第一列和第三列组成索引条目。键列位于非键(内含)列之前。数组中的零表示相应的索引属性是基于表列的表达式,而非简单的列引用。
indcollation oidvectorNOT NULL pg_collation.oid 对于索引键(indnkeyatts 个值)中的每一列,这包含要用于该索引的排序规则的 OID,如果该列的数据类型不支持排序规则则为零。
indclass oidvectorNOT NULL pg_opclass.oid 对于索引键中的每一列(indnkeyatts 个值),这里包含了要使用的操作符类的 OID。详见 pg_opclass。
indoption int2vectorNOT NULL 这是一个包含 indnkeyatts 个值的数组,存储各列的标志位。各位的含义由索引的访问方法定义。
indexprs pg_node_tree 非简单列引用的索引属性所对应的表达式树(以 nodeToString() 表示)。这是一个列表,indkey 中的每个零值条目在此都有一个对应元素。如果所有索引属性都是简单列引用,则为 NULL。
indpred pg_node_tree 部分索引谓词的表达式树(以 nodeToString() 形式)。如果不是部分索引,此列为 NULL。

演化历史

相邻两个大版本之间的差异,新的在前。版本号链到该版的字段表。

  1. PostgreSQL 15 ← 14 结构变更

    indnullsnotdistinct

    1 处描述更新
    • indkey This is an array of indnatts values that indicate which table columns this index indexes. For example a value of 1 3 would mean that the first and the third table columns make up the index entries. Key columns come before non-key (included) columns. A zero in this array indicates that the corresponding index attribute is an expression over the table columns, rather than a simple column reference. This is an array of indnatts values that indicate which table columns this index indexes. For example, a value of 1 3 would mean that the first and the third table columns make up the index entries. Key columns come before non-key (included) columns. A zero in this array indicates that the corresponding index attribute is an expression over the table columns, rather than a simple column reference.
  2. PostgreSQL 11 ← 10 结构变更

    indnkeyatts

    5 处描述更新
    • indclass For each column in the index key, this contains the OID of the operator class to use. See pg_opclass for details. For each column in the index key (indnkeyatts values), this contains the OID of the operator class to use. See pg_opclass for details.
    • indcollation For each column in the index key, this contains the OID of the collation to use for the index, or zero if the column is not of a collatable data type. For each column in the index key (indnkeyatts values), this contains the OID of the collation to use for the index, or zero if the column is not of a collatable data type.
    • indkey This is an array of indnatts values that indicate which table columns this index indexes. For example a value of 1 3 would mean that the first and the third table columns make up the index key. A zero in this array indicates that the corresponding index attribute is an expression over the table columns, rather than a simple column reference. This is an array of indnatts values that indicate which table columns this index indexes. For example a value of 1 3 would mean that the first and the third table columns make up the index entries. Key columns come before non-key (included) columns. A zero in this array indicates that the corresponding index attribute is an expression over the table columns, rather than a simple column reference.
    • indnatts The number of columns in the index (duplicates pg_class.relnatts) The total number of columns in the index (duplicates pg_class.relnatts); this number includes both key and included attributes
    • indoption This is an array of indnatts values that store per-column flag bits. The meaning of the bits is defined by the index's access method. This is an array of indnkeyatts values that store per-column flag bits. The meaning of the bits is defined by the index's access method.
  3. PostgreSQL 10 ← 9.6 仅描述更新

    2 处描述更新
    • indcollation For each column in the index key, this contains the OID of the collation to use for the index. For each column in the index key, this contains the OID of the collation to use for the index, or zero if the column is not of a collatable data type.
    • indisreplident If true this index has been chosen as "replica identity" using ALTER TABLE ... REPLICA IDENTITY USING INDEX ... If true this index has been chosen as “replica identity” using ALTER TABLE ... REPLICA IDENTITY USING INDEX ...
  4. PostgreSQL 9.4 ← 9.3 结构变更

    indisreplident

  5. PostgreSQL 9.3 ← 9.2 结构变更

    indislive

    1 处描述更新
    • indisvalid If both this flag and indisready are true, the index is currently valid for queries. False means the index is possibly incomplete: it must still be modified by INSERT/UPDATE operations, but it cannot safely be used for queries. If it is unique, the uniqueness property is not guaranteed true either. If true, the index is currently valid for queries. False means the index is possibly incomplete: it must still be modified by INSERT/UPDATE operations, but it cannot safely be used for queries. If it is unique, the uniqueness property is not guaranteed true either.
  6. PostgreSQL 9.2 ← 9.1 仅描述更新

    1 处描述更新
    • indisvalid If true, the index is currently valid for queries. False means the index is possibly incomplete: it must still be modified by INSERT/UPDATE operations, but it cannot safely be used for queries. If it is unique, the uniqueness property is not true either. If both this flag and indisready are true, the index is currently valid for queries. False means the index is possibly incomplete: it must still be modified by INSERT/UPDATE operations, but it cannot safely be used for queries. If it is unique, the uniqueness property is not guaranteed true either.
  7. PostgreSQL 9.1 ← 9.0 结构变更

    indisexclusionindcollation indexprs:text → pg_node_treeindpred:text → pg_node_tree

    1 处描述更新
    • indimmediate If true, the uniqueness check is enforced immediately on insertion (indisunique should always be true when this is true) If true, the uniqueness check is enforced immediately on insertion (irrelevant if indisunique is not true)
  8. PostgreSQL 9.0 ← 8.4 结构变更

    indimmediate

  9. PostgreSQL 8.3 ← 8.2 结构变更

    indcheckxminindisreadyindoption

  10. PostgreSQL 8.2 ← 8.1 结构变更

    indisvalid

  11. PostgreSQL 8.1 ← 8.0 结构变更

    字段顺序调整

字段矩阵

每个字段在 24 个收录版本里的存在情况;方格指向该版的字段表。「有变」指类型、可空、隐式或数组维数与上一版不同。

存在 有变 已移除 不存在

字段 7.48.08.18.28.38.49.09.19.29.39.49.59.61011121314151617181920
indexrelid 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indrelid 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indkey 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indclass 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indnatts 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisunique 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisprimary 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisclustered 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indexprs 存在 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indpred 存在 存在 存在 存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indisvalid 不存在 不存在 不存在 存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indcheckxmin 不存在 不存在 不存在 不存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisready 不存在 不存在 不存在 不存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indoption 不存在 不存在 不存在 不存在 存在 存在 有变 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indimmediate 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisexclusion 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indcollation 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
indislive 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indisreplident 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indnkeyatts 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 有变
indnullsnotdistinct 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 有变

系统列

每张表都有的 6 个系统列
  • tableoidoid-6
  • cmaxcid-5
  • xmaxxid-4
  • cmincid-3
  • xminxid-2
  • ctidtid-1

同类关系

关系 引入 字段 版本变动 最近变更
SYSTEM CATALOG 系统目录表 67 个 ↗
pg_aggregate 7.4基线 22 114 次
聚合函数 现存
pg_am 7.4基线 4 129 次
关系访问方法 现存
pg_amop 7.4基线 9 126 次
访问方法操作符 现存
pg_amproc 7.4基线 6 124 次
访问方法支持函数 现存
pg_attrdef 7.4基线 4 123 次
列默认值 现存
pg_attribute 7.4基线 25 1812 次
表列(“属性”) 现存
pg_auth_members 8.1 7 161 次
授权标识符成员关系 现存
pg_authid 8.1 12 124 次
授权标识符(角色) 现存
pg_autovacuum 8.1 10 8.21 次
目录pg_autovacuum存放自动清理守护进程的可选逐关系配置参数。如果某个特定关系在这里有条目,则给定的参数将用于对该表做自动清理。如果没有条目,将使用系统范围的默认值。关于自动清理守护进程的更多信息,见第 23.1.4 节。 于 8.4 移除
pg_cast 7.4基线 6 123 次
转换(数据类型转换) 现存
pg_class 7.4基线 34 1814 次
表、索引、序列、视图(“关系”) 现存
pg_collation 9.1 12 175 次
排序规则(区域设置信息) 现存
pg_constraint 7.4基线 28 1810 次
检查约束、唯一约束、主键约束、外键约束 现存
pg_conversion 7.4基线 8 123 次
编码转换信息 现存
pg_database 7.4基线 18 1710 次
本数据库集簇中的数据库 现存
pg_db_role_setting 9.0 3 —
每角色和每数据库的设置 现存
pg_default_acl 9.0 5 121 次
对象类型的默认权限 现存
pg_depend 7.4基线 7 —
数据库对象间的依赖 现存
pg_description 7.4基线 4 9.51 次
数据库对象上的描述或注释 现存
pg_enum 8.3 4 123 次
枚举标签和值定义 现存
pg_event_trigger 9.3 7 121 次
事件触发器 现存
pg_extension 9.1 8 122 次
已安装扩展 现存
pg_foreign_data_wrapper 8.4 8 194 次
外部数据包装器定义 现存
pg_foreign_server 8.4 8 122 次
外部服务器定义 现存
pg_foreign_table 9.1 3 —
外部表的补充信息 现存
pg_index 7.4基线 21 159 次
索引的补充信息 现存
pg_inherits 7.4基线 4 141 次
表继承层次 现存
pg_init_privs 9.6 5 —
对象初始权限 现存
pg_language 7.4基线 9 123 次
编写函数的语言 现存
pg_largeobject 7.4基线 3 9.51 次
大对象的数据页 现存
pg_largeobject_metadata 9.0 3 121 次
大对象的元数据 现存
pg_listener 7.4基线 3 —
目录 pg_listener 支持LISTEN和NOTIFY命令。监听者为自己正在监听的每个通知名称在 pg_listener 中创建一个条目。通知者会扫描 pg_listener 并更新每个匹配的条目,以表明发生了一个通知。通知者还会(使用表中记录的 PID)发送信号,把监听者从睡眠中唤醒。 于 9.0 移除
pg_namespace 7.4基线 4 123 次
模式 现存
pg_opclass 7.4基线 9 124 次
访问方法操作符类 现存
pg_operator 7.4基线 15 124 次
操作符 现存
pg_opfamily 8.3 5 122 次
访问方法操作符族 现存
pg_parameter_acl 15 3 —
已授予权限的配置参数 现存
pg_partitioned_table 10 8 111 次
表的分区键的信息 现存
pg_pltemplate 8.1 8 9.53 次
过程语言的模板数据 于 13 移除
pg_policy 9.5 8 122 次
行安全性策略 现存
pg_proc 7.4基线 30 1412 次
函数和过程 现存
pg_publication 10 11 195 次
用于逻辑复制的发布 现存
pg_publication_namespace 15 3 —
模式到发布映射 现存
pg_publication_rel 10 6 193 次
关系与发布的映射 现存
pg_range 9.2 12 192 次
范围类型的信息 现存
pg_replication_origin 9.5 2 —
已注册的复制源 现存
pg_rewrite 7.4基线 8 125 次
查询重写规则 现存
pg_seclabel 9.1 5 9.51 次
数据库对象上的安全标签 现存
pg_sequence 10 8 —
有关序列的信息 现存
pg_shdepend 8.1 7 8.41 次
共享对象上的依赖 现存
pg_shdescription 8.2 3 9.51 次
共享对象上的注释 现存
pg_shseclabel 9.2 4 9.51 次
共享数据库对象上的安全标签 现存
pg_statistic 7.4基线 31 123 次
规划器统计信息 现存
pg_statistic_ext 10 9 174 次
扩展的规划器统计信息(定义) 现存
pg_statistic_ext_data 12 6 152 次
扩展的规划器统计信息(已构建的统计信息) 现存
pg_subscription 10 23 197 次
逻辑复制订阅 现存
pg_subscription_rel 10 4 131 次
订阅的关系状态 现存
pg_tablespace 8.0 5 124 次
本数据库集簇内的表空间 现存
pg_transform 9.5 5 121 次
转换(将数据类型转换为过程语言需要的形式) 现存
pg_trigger 7.4基线 19 137 次
触发器 现存
pg_ts_config 8.3 5 122 次
文本检索配置 现存
pg_ts_config_map 8.3 4 —
文本检索配置的词元映射 现存
pg_ts_dict 8.3 6 122 次
文本检索词典 现存
pg_ts_parser 8.3 8 122 次
文本检索解析器 现存
pg_ts_template 8.3 5 122 次
文本检索模板 现存
pg_type 7.4基线 32 149 次
数据类型 现存
pg_user_mapping 8.4 4 122 次
用户到外部服务器的映射 现存