> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-index.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 52.26. pg\_index \#

### 52.26. `pg_index` [#](#catalog-pg-index) <a href="#catalog-pg-index" id="catalog-pg-index"></a>

目錄 `pg_index` 存放索引的部分資訊，其餘資訊大多位於 [`pg_class`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md) 中。

#### 表 52.26. `pg_index` 欄位 [#](#catalog-pg-index-columns) <a href="#catalog-pg-index-columns" id="catalog-pg-index-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>indexrelid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>oid</code>）</p><p>此索引之 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a> 項目的 OID</p>                                                                        |
| <p><code>indrelid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>oid</code>）</p><p>此索引所屬資料表之 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a> 項目的 OID</p>                                                                     |
| <p><code>indnatts</code> <code>int2</code></p><p>索引中的欄位總數（與 <code>pg\_class.relnatts</code> 重複）；此數目同時包含鍵屬性與包含屬性</p>                                                                                                                                                                                                                                                                 |
| <p><code>indnkeyatts</code> <code>int2</code></p><p>索引中<em>鍵欄位</em>的數目，不計入任何<em>包含欄位</em>；包含欄位僅被儲存，不參與索引語意</p>                                                                                                                                                                                                                                                                      |
| <p><code>indisunique</code> <code>bool</code></p><p>若為 true，此索引為唯一值索引</p>                                                                                                                                                                                                                                                                                                           |
| <p><code>indnullsnotdistinct</code> <code>bool</code></p><p>此值只用於唯一值索引。若為 false，此唯一值索引會將 null 值視為相異（因此索引的一個欄位中可以包含多個 null 值，這是 PostgreSQL 的預設行為）。若為 true，則會將 null 值視為相等（因此索引的一個欄位中只能包含一個 null 值）。</p>                                                                                                                                                                               |
| <p><code>indisprimary</code> <code>bool</code></p><p>若為 true，此索引代表資料表的主鍵（此值為 true 時，<code>indisunique</code> 應該一律為 true）</p>                                                                                                                                                                                                                                                        |
| <p><code>indisexclusion</code> <code>bool</code></p><p>若為 true，此索引支援排除限制條件</p>                                                                                                                                                                                                                                                                                                      |
| <p><code>indimmediate</code> <code>bool</code></p><p>若為 true，唯一性檢查會在插入時立即強制執行（若 <code>indisunique</code> 不為 true，則此欄位無關緊要）</p>                                                                                                                                                                                                                                                      |
| <p><code>indisclustered</code> <code>bool</code></p><p>若為 true，表示資料表上一次是依此索引進行叢集</p>                                                                                                                                                                                                                                                                                                |
| <p><code>indisvalid</code> <code>bool</code></p><p>若為 true，此索引目前可有效用於查詢。false 表示此索引可能不完整：它仍必須由 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-insert.md"><code>INSERT</code></a>/<a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-update.md"><code>UPDATE</code></a> 作業修改，但無法安全地用於查詢。若它是唯一值索引，其唯一性也不保證成立。</p>                                   |
| <p><code>indcheckxmin</code> <code>bool</code></p><p>若為 true，則查詢不得使用此索引，直到 <code>xmin</code>（屬於此 <code>pg\_index</code> 資料列）低於查詢的 <code>TransactionXmin</code> 事件視界（event horizon）為止，因為資料表可能包含損壞的 <a href="https://docs.postgresql.tw/19/internals/storage/storage-hot.md">HOT 鏈</a>，其中有查詢看得到、但與索引不相容的資料列</p>                                                                       |
| <p><code>indisready</code> <code>bool</code></p><p>若為 true，此索引目前已可接受插入。false 表示 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-insert.md"><code>INSERT</code></a>/<a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-update.md"><code>UPDATE</code></a> 作業必須忽略此索引。</p>                                                                            |
| <p><code>indislive</code> <code>bool</code></p><p>若為 false，此索引正在移除過程中，在所有用途上都應該忽略它（包括 HOT 安全性的判斷）</p>                                                                                                                                                                                                                                                                               |
| <p><code>indisreplident</code> <code>bool</code></p><p>若為 true，表示此索引已透過 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-altertable.md#SQL-ALTERTABLE-REPLICA-IDENTITY"><code>ALTER TABLE ... REPLICA IDENTITY USING INDEX ...</code></a> 被選為“複寫識別（replica identity）”</p>                                                                                          |
| <p><code>indkey</code> <code>int2vector</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-attribute.md"><code>pg\_attribute</code></a>.<code>attnum</code>）</p><p>這是由 <code>indnatts</code> 個值組成的陣列，指出此索引所索引的是哪些資料表欄位。例如，值 <code>1 3</code> 表示索引項目由資料表的第一個與第三個欄位構成。鍵欄位排在非鍵（包含）欄位之前。此陣列中的零表示對應的索引屬性是以資料表欄位構成的運算式，而非單純的欄位參照。</p>                        |
| <p><code>indcollation</code> <code>oidvector</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-collation.md"><code>pg\_collation</code></a>.<code>oid</code>）</p><p>對於索引鍵中的每個欄位（共 <code>indnkeyatts</code> 個值），此欄位存放該索引所使用之定序的 OID；若該欄位不是可定序的資料型別則為零。</p>                                                                                             |
| <p><code>indclass</code> <code>oidvector</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-opclass.md"><code>pg\_opclass</code></a>.<code>oid</code>）</p><p>對於索引鍵中的每個欄位（共 <code>indnkeyatts</code> 個值），此欄位存放所使用之運算子類別的 OID。詳細資訊請參閱 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-opclass.md"><code>pg\_opclass</code></a>。</p> |
| <p><code>indoption</code> <code>int2vector</code></p><p>這是由 <code>indnkeyatts</code> 個值組成的陣列，存放每個欄位的旗標位元。這些位元的意義由索引的存取方法定義。</p>                                                                                                                                                                                                                                                     |
| <p><code>indexprs</code> <code>pg\_node\_tree</code></p><p>非單純欄位參照之索引屬性的運算式樹（以 <code>nodeToString()</code> 表示法呈現）。這是一個清單，<code>indkey</code> 中每個為零的項目各對應一個元素。若所有索引屬性都是單純參照則為 null。</p>                                                                                                                                                                                              |
| <p><code>indpred</code> <code>pg\_node\_tree</code></p><p>部分索引述詞的運算式樹（以 <code>nodeToString()</code> 表示法呈現）。若不是部分索引則為 null。</p>                                                                                                                                                                                                                                                      |

<br>

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-index.html)（原文版本：18.6；核對日期：2026-10-17）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-index.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
