> 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/server-administration/monitoring/progress-reporting/create-index-progress-reporting.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 27.4.4. CREATE INDEX 進度回報

## 27.4.4. CREATE INDEX 進度回報 [#](#create-index-progress-reporting) <a href="#create-index-progress-reporting" id="create-index-progress-reporting"></a>

每當 `CREATE INDEX` 或 `REINDEX` 正在執行時，`pg_stat_progress_create_index` 檢視表中，就會針對每個目前正在建立索引的後端， 各含有一列。下方的表格， 說明了會被回報的資訊，並提供如何解讀這些資訊的說明。

### 表 27.43. `pg_stat_progress_create_index` 檢視表 [#](#pg-stat-progress-create-index-view) <a href="#pg-stat-progress-create-index-view" id="pg-stat-progress-create-index-view"></a>

| <p>欄位型別</p><p>說明</p>                                                                                                                                                                      |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>pid</code> <code>integer</code></p><p>正在建立索引之後端的程序 ID。</p>                                                                                                                       |
| <p><code>datid</code> <code>oid</code></p><p>此後端所連線之資料庫的 OID。</p>                                                                                                                         |
| <p><code>datname</code> <code>name</code></p><p>此後端所連線之資料庫的名稱。</p>                                                                                                                        |
| <p><code>relid</code> <code>oid</code></p><p>正在為其建立索引之資料表的 OID。</p>                                                                                                                       |
| <p><code>index\_relid</code> <code>oid</code></p><p>正在建立或重建之索引的 OID。在非並行的 <code>CREATE INDEX</code> 期間，此值為 0。</p>                                                                         |
| <p><code>command</code> <code>text</code></p><p>具體的命令類型：<code>CREATE INDEX</code>、 <code>CREATE INDEX CONCURRENTLY</code>、 <code>REINDEX</code>， 或 <code>REINDEX CONCURRENTLY</code>。</p> |
| <p><code>phase</code> <code>text</code></p><p>目前建立索引的處理階段。請參閱<a href="#create-index-phases">表 27.44</a>。</p>                                                                              |
| <p><code>lockers\_total</code> <code>bigint</code></p><p>在適用情況下，需要等待的鎖定持有者總數。</p>                                                                                                         |
| <p><code>lockers\_done</code> <code>bigint</code></p><p>已等待完成的鎖定持有者數量。</p>                                                                                                                |
| <p><code>current\_locker\_pid</code> <code>bigint</code></p><p>目前正在等待之鎖定持有者的程序 ID。</p>                                                                                                    |
| <p><code>blocks\_total</code> <code>bigint</code></p><p>目前階段中要處理的區塊總數。</p>                                                                                                                |
| <p><code>blocks\_done</code> <code>bigint</code></p><p>目前階段中已處理的區塊數。</p>                                                                                                                  |
| <p><code>tuples\_total</code> <code>bigint</code></p><p>目前階段中要處理的資料列總數。</p>                                                                                                               |
| <p><code>tuples\_done</code> <code>bigint</code></p><p>目前階段中已處理的資料列數。</p>                                                                                                                 |
| <p><code>partitions\_total</code> <code>bigint</code></p><p>要為其建立或附加索引的分割區總數， 包含直接與間接的分割區。此值為 <code>0</code> 的情況， 是在進行 <code>REINDEX</code> 期間，或該索引未分割時。</p>                              |
| <p><code>partitions\_done</code> <code>bigint</code></p><p>已為其建立或附加索引的分割區數量， 包含直接與間接的分割區。此值為 <code>0</code> 的情況， 是在進行 <code>REINDEX</code> 期間，或該索引未分割時。</p>                               |

<br>

### 表 27.44. CREATE INDEX 各階段 [#](#create-index-phases) <a href="#create-index-phases" id="create-index-phases"></a>

| 階段                                        | 說明                                                                                                                                                                      |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initializing`                            | `CREATE INDEX` 或 `REINDEX` 正在準備建立索引。預期此階段耗時應非常短暫。                                                                                                                       |
| `waiting for writers before build`        | `CREATE INDEX CONCURRENTLY` 或 `REINDEX CONCURRENTLY`， 正在等待可能看得到該資料表、且持有寫入鎖定的交易結束。此階段在非並行模式下會被跳過。 欄位 `lockers_total`、 `lockers_done` 與 `current_locker_pid`， 含有此階段的進度資訊。 |
| `building index`                          | 正在由存取方法特有的程式碼建立索引。 在此階段中，支援進度回報的存取方法， 會填入自己的進度資料， 並在此欄位中標示子階段。一般而言， `blocks_total` 與 `blocks_done`， 將含有進度資料，也可能包含 `tuples_total` 與 `tuples_done`。                       |
| `waiting for writers before validation`   | `CREATE INDEX CONCURRENTLY` 或 `REINDEX CONCURRENTLY`， 正在等待可能會寫入該資料表、且持有寫入鎖定的交易結束。此階段在非並行模式下會被跳過。 欄位 `lockers_total`、 `lockers_done` 與 `current_locker_pid`， 含有此階段的進度資訊。 |
| `index validation: scanning index`        | `CREATE INDEX CONCURRENTLY` 正在掃描該索引，尋找需要被驗證的 資料列。 此階段在非並行模式下會被跳過。 欄位 `blocks_total` （設為該索引的總大小）與 `blocks_done`， 含有此階段的進度資訊。                                             |
| `index validation: sorting tuples`        | `CREATE INDEX CONCURRENTLY` 正在排序索引掃描階段的輸出結果。                                                                                                                            |
| `index validation: scanning table`        | `CREATE INDEX CONCURRENTLY` 正在掃描該資料表， 以驗證前兩個階段所蒐集到的索引 資料列。 此階段在非並行模式下會被跳過。 欄位 `blocks_total` （設為該資料表的總大小）與 `blocks_done`， 含有此階段的進度資訊。                                   |
| `waiting for old snapshots`               | `CREATE INDEX CONCURRENTLY` 或 `REINDEX CONCURRENTLY`， 正在等待可能看得到該資料表的交易， 釋出其快照。此階段在非並行模式下會被跳過。 欄位 `lockers_total`、 `lockers_done` 與 `current_locker_pid`， 含有此階段的進度資訊。    |
| `waiting for readers before marking dead` | `REINDEX CONCURRENTLY`， 正在等待對該資料表持有讀取鎖定的交易結束， 才將舊索引標示為失效（dead）。 此階段在非並行模式下會被跳過。 欄位 `lockers_total`、 `lockers_done` 與 `current_locker_pid`， 含有此階段的進度資訊。                  |
| `waiting for readers before dropping`     | `REINDEX CONCURRENTLY`， 正在等待對該資料表持有讀取鎖定的交易結束， 才捨棄舊索引。 此階段在非並行模式下會被跳過。 欄位 `lockers_total`、 `lockers_done` 與 `current_locker_pid`， 含有此階段的進度資訊。                            |

<br>

[返回 27.4. 進度回報](https://docs.postgresql.tw/19/server-administration/monitoring/progress-reporting.md#progress-reporting)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/progress-reporting.html)（原文版本：18.6；核對日期：2026-09-26）


---

# 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/server-administration/monitoring/progress-reporting/create-index-progress-reporting.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.
