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

# 27.4.5. VACUUM 進度回報

## 27.4.5. VACUUM 進度回報 [#](#vacuum-progress-reporting) <a href="#vacuum-progress-reporting" id="vacuum-progress-reporting"></a>

每當 `VACUUM` 正在執行時， `pg_stat_progress_vacuum` 檢視表中， 就會針對每個目前正在執行清理（vacuum）的後端 （包括自動 vacuum 工作程序），各含有一列。 下方的表格，說明了會被回報的資訊， 並提供如何解讀這些資訊的說明。 `VACUUM FULL` 命令的進度， 是透過 `pg_stat_progress_cluster` 回報的，因為 `VACUUM FULL` 與 `CLUSTER` 都會重寫資料表， 而一般的 `VACUUM` 則只會就地修改資料表。 請參閱 [27.4.2 節](https://docs.postgresql.tw/19/server-administration/monitoring/progress-reporting/cluster-progress-reporting.md#cluster-progress-reporting)。

### 表 27.45. `pg_stat_progress_vacuum` 檢視表 [#](#pg-stat-progress-vacuum-view) <a href="#pg-stat-progress-vacuum-view" id="pg-stat-progress-vacuum-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>phase</code> <code>text</code></p><p>目前清理的處理階段。請參閱<a href="#vacuum-phases">表 27.46</a>。</p>                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p><code>heap\_blks\_total</code> <code>bigint</code></p><p>該資料表中堆積區塊的總數。此數字是在 掃描開始時所回報的；之後新增的區塊， 不會（也不需要）被本次 <code>VACUUM</code> 造訪。</p>                                                                                                                                                                                                                                                                                                                                                                        |
| <p><code>heap\_blks\_scanned</code> <code>bigint</code></p><p>已掃描的堆積區塊數。由於 <a href="https://docs.postgresql.tw/19/internals/storage/storage-vm.md">能見度映射（visibility map）</a> 被用來最佳化掃描，有些區塊會被跳過而不進行檢查； 這些被跳過的區塊，也計入此總數中， 因此當清理完成時，此數字最終會等於 <code>heap\_blks\_total</code>。 此計數器只會在階段為 <code>scanning heap</code> 時才會前進。</p>                                                                                                                                                                                       |
| <p><code>heap\_blks\_vacuumed</code> <code>bigint</code></p><p>已清理的堆積區塊數。除非該資料表沒有索引， 否則此計數器只會在階段為 <code>vacuuming heap</code> 時才會前進。 不含死亡資料列的區塊會被跳過， 因此此計數器有時可能會以大幅度往前跳。</p>                                                                                                                                                                                                                                                                                                                                     |
| <p><code>index\_vacuum\_count</code> <code>bigint</code></p><p>已完成的索引清理循環次數。</p>                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| <p><code>max\_dead\_tuple\_bytes</code> <code>bigint</code></p><p>依據 <a href="https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-MAINTENANCE-WORK-MEM">maintenance\_work\_mem</a>， 在需要執行索引清理循環之前， 我們能夠儲存的死亡資料列資料量。</p>                                                                                                                                                                                                                                            |
| <p><code>dead\_tuple\_bytes</code> <code>bigint</code></p><p>自上次索引清理循環以來， 所蒐集到的死亡資料列資料量。</p>                                                                                                                                                                                                                                                                                                                                                                                                                     |
| <p><code>num\_dead\_item\_ids</code> <code>bigint</code></p><p>自上次索引清理循環以來， 所蒐集到的死亡項目識別碼數量。</p>                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <p><code>indexes\_total</code> <code>bigint</code></p><p>將被清理（vacuum）或清除（clean up）的索引總數。此數字是在 <code>vacuuming indexes</code> 階段， 或 <code>cleaning up indexes</code> 階段開始時回報的。</p>                                                                                                                                                                                                                                                                                                                                |
| <p><code>indexes\_processed</code> <code>bigint</code></p><p>已處理的索引數量。此計數器只會在 階段為 <code>vacuuming indexes</code> 或 <code>cleaning up indexes</code> 時才會前進。</p>                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>delay\_time</code> <code>double precision</code></p><p>因基於成本的延遲（請參閱 <a href="https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-vacuum.md#runtime-config-resource-vacuum-cost">19.10.2 節</a>） 而耗費在休眠上的總時間，以毫秒為單位 （若已啟用 <a href="https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-statistics.md#GUC-TRACK-COST-DELAY-TIMING">track\_cost\_delay\_timing</a>， 否則為零）。這包括任何相關聯的平行工作者 休眠的時間。然而，平行工作者回報其休眠時間的頻率 最多為每秒一次，因此所回報的值， 可能會略微過時。</p> |

<br>

### 表 27.46. VACUUM 各階段 [#](#vacuum-phases) <a href="#vacuum-phases" id="vacuum-phases"></a>

| 階段                         | 說明                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `initializing`             | `VACUUM` 正在準備開始掃描堆積。預期此階段 耗時應非常短暫。                                                                                                                                                                                                                                                                                                                                                                                       |
| `scanning heap`            | `VACUUM` 目前正在掃描堆積。若有需要，它會對每個頁面進行 修剪與重組，並可能執行凍結作業。 `heap_blks_scanned` 欄位， 可用來監控此次掃描的進度。                                                                                                                                                                                                                                                                                                                                  |
| `vacuuming indexes`        | `VACUUM` 目前正在清理索引。若某個資料表含有 任何索引，此動作在堆積完全掃描完成後， 每次清理至少會發生一次。若 [maintenance\_work\_mem](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-MAINTENANCE-WORK-MEM) （或在自動 vacuum 的情況下， 若有設定 [autovacuum\_work\_mem](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-AUTOVACUUM-WORK-MEM)） 不足以儲存所找到的死亡資料列數量， 則此動作每次清理可能會發生多次。 |
| `vacuuming heap`           | `VACUUM` 目前正在清理堆積。清理堆積 與掃描堆積不同，會在每次清理索引之後發生。 若 `heap_blks_scanned` 小於 `heap_blks_total`， 此階段完成後，系統就會回到掃描堆積； 否則，此階段完成後， 系統就會開始清除索引。                                                                                                                                                                                                                                                                                       |
| `cleaning up indexes`      | `VACUUM` 目前正在清除索引。這會在堆積已完全掃描完成， 且索引與堆積的所有清理動作都已完成後發生。                                                                                                                                                                                                                                                                                                                                                                    |
| `truncating heap`          | `VACUUM` 目前正在截斷堆積， 以將該關聯結尾的空白頁面，交還給作業系統。 這會在清理索引之後發生。                                                                                                                                                                                                                                                                                                                                                                    |
| `performing final cleanup` | `VACUUM` 正在執行最終清理。在此階段期間， `VACUUM` 會清理可用空間對應表（free space map）、 更新 `pg_class` 中的統計資訊， 並向累計統計資訊系統回報統計資訊。此階段完成後， `VACUUM` 就會結束。                                                                                                                                                                                                                                                                                             |

<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/vacuum-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.
