SYSTEM CATALOG系统目录表
pg_index
索引的补充信息
系统目录表 引入 9.0(基线) 现存至 20 devel 5 次结构变更
版本轨迹
相对 PostgreSQL 17 无变化。
目录pg_index包含关于索引的部分信息。其他信息大部分在pg_class中。
字段
PostgreSQL 18 的 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。 |
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的字段表。
-
PostgreSQL 15 ← 14 结构变更
indnullsnotdistinct1 处描述更新
indkeyThis 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.
-
PostgreSQL 11 ← 10 结构变更
indnkeyatts5 处描述更新
indclassFor 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.indcollationFor 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.indkeyThis 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.indnattsThe 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 attributesindoptionThis 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.
-
PostgreSQL 10 ← 9.6 仅描述更新
2 处描述更新
indcollationFor 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.indisreplidentIf 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 ...
-
PostgreSQL 9.4 ← 9.3 结构变更
indisreplident -
PostgreSQL 9.3 ← 9.2 结构变更
indislive1 处描述更新
indisvalidIf 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.
-
PostgreSQL 9.2 ← 9.1 仅描述更新
1 处描述更新
indisvalidIf 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.
-
PostgreSQL 9.1 ← 9.0 结构变更
indisexclusionindcollationindexprs:text → pg_node_treeindpred:text → pg_node_tree1 处描述更新
indimmediateIf 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)
字段矩阵
每个字段在 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
indexrelid |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indrelid |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indnatts |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisunique |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisprimary |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indimmediate |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisclustered |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisvalid |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indcheckxmin |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisready |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indkey |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indclass |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indoption |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indexprs |
存在 | 有变 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indpred |
存在 | 有变 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisexclusion |
不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indcollation |
不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indislive |
不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indisreplident |
不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indnkeyatts |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
indnullsnotdistinct |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 |
系统列
每张表都有的 6 个系统列
tableoidoid-6cmaxcid-5xmaxxid-4cmincid-3xminxid-2ctidtid-1
同类关系
| 关系 | 引入 | 字段 | 版本变动 | 最近变更 |
|---|---|---|---|---|
pg_aggregate |
9.0基线 | 22 | 113 次 | |
| 聚合函数 | 现存 | |||
pg_am |
9.0基线 | 4 | 124 次 | |
| 关系访问方法 | 现存 | |||
pg_amop |
9.0基线 | 9 | 122 次 | |
| 访问方法操作符 | 现存 | |||
pg_amproc |
9.0基线 | 6 | 121 次 | |
| 访问方法支持函数 | 现存 | |||
pg_attrdef |
9.0基线 | 4 | 122 次 | |
| 列默认值 | 现存 | |||
pg_attribute |
9.0基线 | 25 | 189 次 | |
| 表列(“属性”) | 现存 | |||
pg_auth_members |
9.0基线 | 7 | 161 次 | |
| 授权标识符成员关系 | 现存 | |||
pg_authid |
9.0基线 | 12 | 123 次 | |
| 授权标识符(角色) | 现存 | |||
pg_cast |
9.0基线 | 6 | 121 次 | |
| 转换(数据类型转换) | 现存 | |||
pg_class |
9.0基线 | 34 | 189 次 | |
| 表、索引、序列、视图(“关系”) | 现存 | |||
pg_collation |
9.1 | 12 | 175 次 | |
| 排序规则(区域设置信息) | 现存 | |||
pg_constraint |
9.0基线 | 28 | 187 次 | |
| 检查约束、唯一约束、主键约束、外键约束 | 现存 | |||
pg_conversion |
9.0基线 | 8 | 121 次 | |
| 编码转换信息 | 现存 | |||
pg_database |
9.0基线 | 18 | 175 次 | |
| 本数据库集簇中的数据库 | 现存 | |||
pg_db_role_setting |
9.0基线 | 3 | — | |
| 每角色和每数据库的设置 | 现存 | |||
pg_default_acl |
9.0基线 | 5 | 121 次 | |
| 对象类型的默认权限 | 现存 | |||
pg_depend |
9.0基线 | 7 | — | |
| 数据库对象间的依赖 | 现存 | |||
pg_description |
9.0基线 | 4 | 9.51 次 | |
| 数据库对象上的描述或注释 | 现存 | |||
pg_enum |
9.0基线 | 4 | 122 次 | |
| 枚举标签和值定义 | 现存 | |||
pg_event_trigger |
9.3 | 7 | 121 次 | |
| 事件触发器 | 现存 | |||
pg_extension |
9.1 | 8 | 122 次 | |
| 已安装扩展 | 现存 | |||
pg_foreign_data_wrapper |
9.0基线 | 8 | 193 次 | |
| 外部数据包装器定义 | 现存 | |||
pg_foreign_server |
9.0基线 | 8 | 121 次 | |
| 外部服务器定义 | 现存 | |||
pg_foreign_table |
9.1 | 3 | — | |
| 外部表的补充信息 | 现存 | |||
pg_index |
9.0基线 | 21 | 155 次 | |
| 索引的补充信息 | 现存 | |||
pg_inherits |
9.0基线 | 4 | 141 次 | |
| 表继承层次 | 现存 | |||
pg_init_privs |
9.6 | 5 | — | |
| 对象初始权限 | 现存 | |||
pg_language |
9.0基线 | 9 | 121 次 | |
| 编写函数的语言 | 现存 | |||
pg_largeobject |
9.0基线 | 3 | 9.51 次 | |
| 大对象的数据页 | 现存 | |||
pg_largeobject_metadata |
9.0基线 | 3 | 121 次 | |
| 大对象的元数据 | 现存 | |||
pg_namespace |
9.0基线 | 4 | 121 次 | |
| 模式 | 现存 | |||
pg_opclass |
9.0基线 | 9 | 121 次 | |
| 访问方法操作符类 | 现存 | |||
pg_operator |
9.0基线 | 15 | 121 次 | |
| 操作符 | 现存 | |||
pg_opfamily |
9.0基线 | 5 | 121 次 | |
| 访问方法操作符族 | 现存 | |||
pg_parameter_acl |
15 | 3 | — | |
| 已授予权限的配置参数 | 现存 | |||
pg_partitioned_table |
10 | 8 | 111 次 | |
| 表的分区键的信息 | 现存 | |||
pg_pltemplate |
9.0基线 | 8 | 9.51 次 | |
| 过程语言的模板数据 | 于 13 移除 | |||
pg_policy |
9.5 | 8 | 122 次 | |
| 行安全性策略 | 现存 | |||
pg_proc |
9.0基线 | 30 | 147 次 | |
| 函数和过程 | 现存 | |||
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 |
9.0基线 | 8 | 123 次 | |
| 查询重写规则 | 现存 | |||
pg_seclabel |
9.1 | 5 | 9.51 次 | |
| 数据库对象上的安全标签 | 现存 | |||
pg_sequence |
10 | 8 | — | |
| 有关序列的信息 | 现存 | |||
pg_shdepend |
9.0基线 | 7 | — | |
| 共享对象上的依赖 | 现存 | |||
pg_shdescription |
9.0基线 | 3 | 9.51 次 | |
| 共享对象上的注释 | 现存 | |||
pg_shseclabel |
9.2 | 4 | 9.51 次 | |
| 共享数据库对象上的安全标签 | 现存 | |||
pg_statistic |
9.0基线 | 31 | 122 次 | |
| 规划器统计信息 | 现存 | |||
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 |
9.0基线 | 5 | 122 次 | |
| 本数据库集簇内的表空间 | 现存 | |||
pg_transform |
9.5 | 5 | 121 次 | |
| 转换(将数据类型转换为过程语言需要的形式) | 现存 | |||
pg_trigger |
9.0基线 | 19 | 135 次 | |
| 触发器 | 现存 | |||
pg_ts_config |
9.0基线 | 5 | 121 次 | |
| 文本检索配置 | 现存 | |||
pg_ts_config_map |
9.0基线 | 4 | — | |
| 文本检索配置的词元映射 | 现存 | |||
pg_ts_dict |
9.0基线 | 6 | 121 次 | |
| 文本检索词典 | 现存 | |||
pg_ts_parser |
9.0基线 | 8 | 121 次 | |
| 文本检索解析器 | 现存 | |||
pg_ts_template |
9.0基线 | 5 | 121 次 | |
| 文本检索模板 | 现存 | |||
pg_type |
9.0基线 | 32 | 144 次 | |
| 数据类型 | 现存 | |||
pg_user_mapping |
9.0基线 | 4 | 121 次 | |
| 用户到外部服务器的映射 | 现存 | |||