> 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/monitoring-stats/monitoring-pg-stat-all-tables-view.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 27.2.19. pg\_stat\_all\_tables

## 27.2.19. `pg_stat_all_tables` [#](#monitoring-pg-stat-all-tables-view) <a href="#monitoring-pg-stat-all-tables-view" id="monitoring-pg-stat-all-tables-view"></a>

`pg_stat_all_tables` 檢視表中，目前資料庫中的 每個資料表（包括 TOAST 資料表）各會有一筆資料列，顯示有關對該特定資料表存取情形的統計資訊。 `pg_stat_user_tables` 與 `pg_stat_sys_tables` 檢視表 包含相同的資訊， 但分別經過篩選，僅顯示使用者資料表與系統資料表。

### 表 27.29. `pg_stat_all_tables` 檢視表 [#](#pg-stat-all-tables-view) <a href="#pg-stat-all-tables-view" id="pg-stat-all-tables-view"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>relid</code> <code>oid</code></p><p>某個資料表的 OID</p>                                                                                                                                                                                                                                        |
| <p><code>schemaname</code> <code>name</code></p><p>此資料表所屬綱要的名稱</p>                                                                                                                                                                                                                                 |
| <p><code>relname</code> <code>name</code></p><p>此資料表的名稱</p>                                                                                                                                                                                                                                        |
| <p><code>seq\_scan</code> <code>bigint</code></p><p>在此資料表上發起的循序掃描次數</p>                                                                                                                                                                                                                            |
| <p><code>last\_seq\_scan</code> <code>timestamp with time zone</code></p><p>此資料表上最後一次循序掃描的時間，根據最近一次 交易停止的時間計算</p>                                                                                                                                                                                  |
| <p><code>seq\_tup\_read</code> <code>bigint</code></p><p>由循序掃描擷取的存活資料列數</p>                                                                                                                                                                                                                        |
| <p><code>idx\_scan</code> <code>bigint</code></p><p>在此資料表上發起的索引掃描次數</p>                                                                                                                                                                                                                            |
| <p><code>last\_idx\_scan</code> <code>timestamp with time zone</code></p><p>此資料表上最後一次索引掃描的時間，根據最近一次 交易停止的時間計算</p>                                                                                                                                                                                  |
| <p><code>idx\_tup\_fetch</code> <code>bigint</code></p><p>由索引掃描擷取的存活資料列數</p>                                                                                                                                                                                                                       |
| <p><code>n\_tup\_ins</code> <code>bigint</code></p><p>已插入的資料列總數</p>                                                                                                                                                                                                                                |
| <p><code>n\_tup\_upd</code> <code>bigint</code></p><p>已更新的資料列總數。（此欄位包含計入 <code>n\_tup\_hot\_upd</code> 與 <code>n\_tup\_newpage\_upd</code> 的資料列更新， 以及其餘非 HOT 更新。）</p>                                                                                                                              |
| <p><code>n\_tup\_del</code> <code>bigint</code></p><p>已刪除的資料列總數</p>                                                                                                                                                                                                                                |
| <p><code>n\_tup\_hot\_upd</code> <code>bigint</code></p><p><a href="https://docs.postgresql.tw/19/internals/storage/storage-hot.md">HOT 更新</a>的資料列數量。 這些是不需要在索引中建立後續版本的 更新。</p>                                                                                                                    |
| <p><code>n\_tup\_newpage\_upd</code> <code>bigint</code></p><p>更新後版本被放置於一個<em>新</em>堆積分頁上， 而留下具有指向不同堆積分頁之 <a href="https://docs.postgresql.tw/19/internals/storage/storage-page-layout/storage-tuple-layout.md#storage-tuple-layout"><code>t\_ctid</code> 欄位</a>之原始版本的資料列更新數量。這些 一律屬於非 HOT 更新。</p> |
| <p><code>n\_live\_tup</code> <code>bigint</code></p><p>估計的存活資料列數</p>                                                                                                                                                                                                                               |
| <p><code>n\_dead\_tup</code> <code>bigint</code></p><p>估計的死亡資料列數</p>                                                                                                                                                                                                                               |
| <p><code>n\_mod\_since\_analyze</code> <code>bigint</code></p><p>自此資料表上次 analyze 以來，估計被修改的資料列數</p>                                                                                                                                                                                                 |
| <p><code>n\_ins\_since\_vacuum</code> <code>bigint</code></p><p>自此資料表上次 vacuum 以來（不計入 <code>VACUUM FULL</code>），估計被插入的資料列數</p>                                                                                                                                                                     |
| <p><code>last\_vacuum</code> <code>timestamp with time zone</code></p><p>此資料表最後一次被手動清理（vacuum） （不計入 <code>VACUUM FULL</code>）的時間</p>                                                                                                                                                               |
| <p><code>last\_autovacuum</code> <code>timestamp with time zone</code></p><p>此資料表最後一次被 autovacuum 常駐程序清理（vacuum） 的時間</p>                                                                                                                                                                           |
| <p><code>last\_analyze</code> <code>timestamp with time zone</code></p><p>此資料表最後一次被手動分析（analyze） 的時間</p>                                                                                                                                                                                           |
| <p><code>last\_autoanalyze</code> <code>timestamp with time zone</code></p><p>此資料表最後一次被 autovacuum 常駐程序分析（analyze） 的時間</p>                                                                                                                                                                         |
| <p><code>vacuum\_count</code> <code>bigint</code></p><p>此資料表被手動清理（vacuum） （不計入 <code>VACUUM FULL</code>）的次數</p>                                                                                                                                                                                    |
| <p><code>autovacuum\_count</code> <code>bigint</code></p><p>此資料表被 autovacuum 常駐程序清理（vacuum） 的次數</p>                                                                                                                                                                                                |
| <p><code>analyze\_count</code> <code>bigint</code></p><p>此資料表被手動分析（analyze） 的次數</p>                                                                                                                                                                                                                |
| <p><code>autoanalyze\_count</code> <code>bigint</code></p><p>此資料表被 autovacuum 常駐程序分析（analyze） 的次數</p>                                                                                                                                                                                              |
| <p><code>total\_vacuum\_time</code> <code>double precision</code></p><p>此資料表被手動清理（vacuum）（不計入 <code>VACUUM FULL</code>）的總時間，以毫秒為單位。 （此欄位包含因成本延遲而休眠所花費的時間。）</p>                                                                                                                                     |
| <p><code>total\_autovacuum\_time</code> <code>double precision</code></p><p>此資料表被 autovacuum 常駐程序清理（vacuum） 的總時間， 以毫秒為單位。（此欄位包含因成本延遲而休眠 所花費的時間。）</p>                                                                                                                                               |
| <p><code>total\_analyze\_time</code> <code>double precision</code></p><p>此資料表被手動分析（analyze） 的總時間，以毫秒為單位。 （此欄位包含因成本延遲而休眠所花費的時間。）</p>                                                                                                                                                                |
| <p><code>total\_autoanalyze\_time</code> <code>double precision</code></p><p>此資料表被 autovacuum 常駐程序分析（analyze） 的總時間， 以毫秒為單位。（此欄位包含因成本延遲而休眠 所花費的時間。）</p>                                                                                                                                             |

<br>

[返回 27.2. 累計統計系統](https://docs.postgresql.tw/19/server-administration/monitoring/monitoring-stats.md#monitoring-stats)

***

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


---

# 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/monitoring-stats/monitoring-pg-stat-all-tables-view.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.
