> 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/internals/views/view-pg-prepared-statements.md).

# 53.16. pg\_prepared\_statements \#

The `pg_prepared_statements` view displays all the prepared statements that are available in the current session. See [PREPARE](/reference/sql-commands/sql-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`](/reference/sql-commands/sql-deallocate.md) command).

**Table 53.16. `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>result\_types</code> <code>regtype\[]</code></p><p>The types of the columns returned by 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>. If the prepared statement does not provide a result (e.g., a DML statement), then this field will be null.</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>                                                                                                                                                                                                                                                                                                                         |

<br>

The `pg_prepared_statements` view is read-only.

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-prepared-statements.html)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/internals/views/view-pg-prepared-statements.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
