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

# 53.17. pg\_prepared\_xacts \#

### 53.17. `pg_prepared_xacts` [#](#view-pg-prepared-xacts) <a href="#view-pg-prepared-xacts" id="view-pg-prepared-xacts"></a>

檢視表 `pg_prepared_xacts` 顯示目前已為兩階段提交而準備之交易的相關資訊（詳情請參閱 [PREPARE TRANSACTION](https://docs.postgresql.tw/19/reference/sql-commands/sql-prepare-transaction.md)）。

`pg_prepared_xacts` 中每個已準備交易各有一筆資料列。當交易被提交或回復時，對應的項目就會被移除。

#### 表 53.17. `pg_prepared_xacts` 欄位 [#](#view-pg-prepared-xacts-columns) <a href="#view-pg-prepared-xacts-columns" id="view-pg-prepared-xacts-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                        |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>transaction</code> <code>xid</code></p><p>已準備交易的數值交易識別碼</p>                                                                                                                                        |
| <p><code>gid</code> <code>text</code></p><p>指派給此交易的全域交易識別碼</p>                                                                                                                                              |
| <p><code>prepared</code> <code>timestamptz</code></p><p>此交易為提交而準備完成的時間</p>                                                                                                                                  |
| <p><code>owner</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md"><code>pg\_authid</code></a>.<code>rolname</code>）</p><p>執行此交易之使用者的名稱</p>        |
| <p><code>database</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-database.md"><code>pg\_database</code></a>.<code>datname</code>）</p><p>執行此交易之資料庫的名稱</p> |

<br>

存取 `pg_prepared_xacts` 檢視表時，內部交易管理器的資料結構會被短暫鎖定，並製作一份副本供此檢視表顯示。這能確保此檢視表產生一致的結果集，同時不會阻擋一般操作超過必要的時間。儘管如此，若頻繁存取此檢視表，仍可能對資料庫效能造成一些影響。

***

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


---

# 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/views/view-pg-prepared-xacts.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.
