NavigationContentFooter
Jump toSuggest an edit

Solving maximum prepared statements size reached

Reviewed on 08 July 2024Published on 08 July 2024

Failed to prepare statement

Problem

The error message below appears when trying to create a new prepared statement:

FATAL: failed to prepare statement: adding the prepared statement would exceed the limit of 524288 bytes for client connection: maximum allowed size of prepared statements for connection reached (SQLSTATE 53400).

Cause

The total size of prepared statements on Serverless SQL Databases is limited to 524288 bytes (512 kibibytes) for a single client connection. This limit can be reached for two reasons:

  • You (or the PostgreSQL client you are using) created too many prepared statements in a single PostgreSQL connection.

  • You (or the PostgreSQL client you are using) created a single prepared statement that exceeds the maximum size.

Solution

  • If you (or the PostgreSQL client you are using) created too many prepared statements in a single PostgreSQL connection, reduce the number of prepared statements, or use the deallocate feature to remove prepared statements in an active session:
  1. Execute the command below to list the prepared statements in your current session:

    SELECT * FROM pg_prepared_statements;
  2. Run the command below to remove the desired prepared statement:

    DEALLOCATE prepared_statement_name;
  • If you (or the PostgreSQL client you are using) created a single prepared statement that exceeds the maximum size, remove the query causing the issue, or split it into multiple statements.
Note

This issue is usually caused by long single queries, exceeding thousands of characters, such as thousands of values in a single INSERT statement, or queries using Large Objects.

Was this page helpful?
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway