cockroachdb / cockroachdb/cockroach

sql: de-duplicate prepared statement cache entries

Open
#98,074 0 comments 0 reactions 0 assignees View on GitHub
A-prepared-stmts C-enhancement O-support P-3 T-sql-queries
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.