cockroachdb / cockroachdb/cockroach
sql: de-duplicate prepared statement cache entries
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
There was a customer issue where the customer used a library that prepared each query run by the application with a unique name before executing it. This caused the number of prepared statements to grow continuously, since we currently create an entry in the prepared statement cache for every unique query + name combination. In combination with #98071, this caused the registered SQL memory usage to grow until queries started failing, despite the fact that the application only used ~40 unique queries.
We should reuse prepared statement entries for the same query with different names. This will ensure that memory usage for prepared statements is only proportional to the number of _unique_ queries in the workload.
Jira issue: CRDB-25066
Contributor guide
Assessment
This issue has not been assessed yet.