IBM Support

Prepared Statements Discarded

Troubleshooting


Problem

In DataStax Enterprise (DSE) and Apache Cassandra, a "prepared statement discarded" warning or error typically indicates that the prepared statement cache has reached its maximum capacity, and the database is discarding the least recently used prepared statements to make room for new ones. This situation can have performance implications since discarding prepared statements means they need to be prepared again, which incurs additional overhead.

If you repeatedly see messages about prepared statements being discarded because the cache limit has been reached:

  1. Investigate the root cause of these messages and check whether prepared statements are used correctly by using bind markers for variable parts.: The size of the prepared statement cache is configurable. If the cache size is too small for your application's needs, it may lead to frequent discarding of prepared statements.
  2. You can increase the prepared statement cache size in the cassandra.yaml configuration file. The relevant setting is often prepared_statements_cache_size_mb. Adjusting this value to better suit your workload can reduce the frequency of cache evictions.
Ensure that your application is using prepared statements efficiently. Overuse of unique prepared statements (e.g., by including literal values instead of placeholders) can cause the cache to fill up quickly. Use placeholders for variable parts of queries to maximize the effectiveness of prepared statements.

If you're frequently encountering this issue, it's advisable to review your application's query patterns and the database configuration. Sometimes, the solution might be as simple as increasing the cache size, but in other cases, it might require a more in-depth analysis of how your application prepares and executes queries.



Last Reviewed : 2023-11-13

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB76","label":"Data Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSCR56","label":"IBM DataStax Enterprise"},"ARM Category":[{"code":"","label":""}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Historical Number

ka06R000000HcYfQAK

Document Information

Modified date:
30 January 2026

UID

ibm17258891