↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / System Catalogs

pg_prepared_statements

The pg_prepared_statements view displays all the prepared statements that are available in the current session. See PREPARE 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 command).

English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

kind
view
lang
en
measured attributes
true
metadata release
18.6
runtime columns
name, statement, prepare_time, parameter_types, result_types, from_sql, generic_plans, custom_plans
runtime verified
false
source
english-manual

Definition PG 18

The pg_prepared_statements view displays all the prepared statements that are available in the current session. See PREPARE 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 command).

Catalog columns

ColumnTypeNullabilityDescription
nametextNullableThe identifier of the prepared statement
statementtextNullableThe query string submitted by the client to create this prepared statement. For prepared statements created via SQL, this is the PREPARE statement submitted by the client. For prepared statements created via the frontend/backend protocol, this is the text of the prepared statement itself.
prepare_timetimestamptzNullableThe time at which the prepared statement was created
parameter_typesregtype[]NullableThe expected parameter types for the prepared statement in the form of an array of regtype. The OID corresponding to an element of this array can be obtained by casting the regtype value to oid.
result_typesregtype[]NullableThe types of the columns returned by the prepared statement in the form of an array of regtype. The OID corresponding to an element of this array can be obtained by casting the regtype value to oid. If the prepared statement does not provide a result (e.g., a DML statement), then this field will be null.
from_sqlboolNullabletrue if the prepared statement was created via the PREPARE SQL command; false if the statement was prepared via the frontend/backend protocol
generic_plansint8NullableNumber of times generic plan was chosen
custom_plansint8NullableNumber of times custom plan was chosen

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · catalog-bilingual-repair:901fb3dedd043997a220c494bd72137f2e61d75ded2d5ba0f960d1204626adb2

Text language: en · catalog-bilingual-repair:901fb3dedd043997a220c494bd72137f2e61d75ded2d5ba0f960d1204626adb2