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

# F.25.1. pg\_buffercache 檢視表

## F.25.1. `pg_buffercache` 檢視表 [#](#pgbuffercache-pg-buffercache) <a href="#pgbuffercache-pg-buffercache" id="pgbuffercache-pg-buffercache"></a>

此檢視表所提供欄位的定義如[表 F.14](#pgbuffercache-columns)所示。

### 表 F.14. `pg_buffercache` 欄位 [#](#pgbuffercache-columns) <a href="#pgbuffercache-columns" id="pgbuffercache-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><code>bufferid</code> <code>integer</code></p><p>ID，範圍為 1..<code>shared\_buffers</code></p>                                                                                                                     |
| <p><code>relfilenode</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>relfilenode</code>）</p><p>關聯的檔案節點（filenode）編號</p> |
| <p><code>reltablespace</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-tablespace.md"><code>pg\_tablespace</code></a>.<code>oid</code>）</p><p>關聯的資料表空間 OID</p>    |
| <p><code>reldatabase</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-database.md"><code>pg\_database</code></a>.<code>oid</code>）</p><p>關聯的資料庫 OID</p>            |
| <p><code>relforknumber</code> <code>smallint</code></p><p>關聯內的分支（fork）編號；請參閱 <code>common/relpath.h</code></p>                                                                                                     |
| <p><code>relblocknumber</code> <code>bigint</code></p><p>關聯內的頁面編號</p>                                                                                                                                              |
| <p><code>isdirty</code> <code>boolean</code></p><p>頁面是否為髒頁？</p>                                                                                                                                                    |
| <p><code>usagecount</code> <code>smallint</code></p><p>時鐘掃描（clock-sweep）存取計數</p>                                                                                                                                   |
| <p><code>pinning\_backends</code> <code>integer</code></p><p>釘住此緩衝區的後端數量</p>                                                                                                                                       |

<br>

共享快取中的每個緩衝區各有一個資料列。未使用的緩衝區除了 `bufferid` 以外，所有欄位皆顯示為 null。共享的系統目錄會顯示為屬於資料庫 0。

由於快取由所有資料庫共享，通常會有來自不屬於目前資料庫之關聯的頁面。這表示對某些資料列而言，`pg_class` 中可能沒有可與之連接的對應資料列，甚至可能產生不正確的連接。若你要與 `pg_class` 連接，最好將連接限制在 `reldatabase` 等於目前資料庫的 OID 或 0 的資料列。

由於複製此檢視表要顯示的緩衝區狀態資料時，不會取得緩衝區管理器的鎖定，存取 `pg_buffercache` 檢視表對正常緩衝區活動的影響較小，但它無法提供在所有緩衝區之間一致的結果集。不過，我們會確保每個緩衝區的資訊本身是一致的。

[返回 F.25. pg\_buffercache — 檢查 PostgreSQL 緩衝區快取狀態](https://docs.postgresql.tw/19/appendixes/contrib/pgbuffercache.md#pgbuffercache)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/pgbuffercache.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/appendixes/contrib/pgbuffercache/pgbuffercache-pg-buffercache.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.
