> 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/15/internals/54.-system-views/pg_prepared_statements.md).

# 54.15. pg\_prepared\_statements

## 54.15. pg\_prepared\_statements

The `pg_prepared_statements` view displays all the prepared statements that are available in the current session. See [PREPARE](/15/reference/sql-commands/prepare.md) for more information about prepared statements.

`pg_prepared_statements` contains one row for each prepared statement. Rows are added to the view when a new prepared statement is created and removed when a prepared statement is released (for example, via the [`DEALLOCATE`](/15/reference/sql-commands/deallocate.md) command).

**Table 54.15. `pg_prepared_statements` Columns**

| <p>Column Type</p><p>Description</p>                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>name</code> <code>text</code></p><p>The identifier of the prepared statement</p>                                                                                                                                                                                                                                                                            |
| <p><code>statement</code> <code>text</code></p><p>The query string submitted by the client to create this prepared statement. For prepared statements created via SQL, this is the <code>PREPARE</code> statement submitted by the client. For prepared statements created via the frontend/backend protocol, this is the text of the prepared statement itself.</p> |
| <p><code>prepare\_time</code> <code>timestamptz</code></p><p>The time at which the prepared statement was created</p>                                                                                                                                                                                                                                                |
| <p><code>parameter\_types</code> <code>regtype\[]</code></p><p>The expected parameter types for the prepared statement in the form of an array of <code>regtype</code>. The OID corresponding to an element of this array can be obtained by casting the <code>regtype</code> value to <code>oid</code>.</p>                                                         |
| <p><code>from\_sql</code> <code>bool</code></p><p><code>true</code> if the prepared statement was created via the <code>PREPARE</code> SQL command; <code>false</code> if the statement was prepared via the frontend/backend protocol</p>                                                                                                                           |
| <p><code>generic\_plans</code> <code>int8</code></p><p>Number of times generic plan was chosen</p>                                                                                                                                                                                                                                                                   |
| <p><code>custom\_plans</code> <code>int8</code></p><p>Number of times custom plan was chosen</p>                                                                                                                                                                                                                                                                     |

The `pg_prepared_statements` view is read-only.

***

原文：[PostgreSQL 15.19 Documentation](/15/internals/54.-system-views/pg_prepared_statements.md)（英文原文，待翻譯）


---

# 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/15/internals/54.-system-views/pg_prepared_statements.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.
