Skip to content

perf(spanner-jdbc): cache commonly used query parameter names - #14036

Open
olavloite wants to merge 1 commit into
mainfrom
spanner-cache-common-param-names
Open

perf(spanner-jdbc): cache commonly used query parameter names#14036
olavloite wants to merge 1 commit into
mainfrom
spanner-cache-common-param-names

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Cache the most commonly used query parameter names for positional parameters to prevent the creation of new strings for every single SQL statement execution.

@olavloite
olavloite requested review from a team as code owners August 11, 2026 13:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a precomputed parameter name cache for indices 1 to 256 in AbstractStatementParser to avoid heap allocations in hot parameter binding loops, updating various classes to use this helper. However, referencing AbstractStatementParser from Statement introduces a circular dependency between the core and connection packages, and is missing an import in Statement.java which will cause a compilation error. It is recommended to move the parameter name cache and utility method to a class within the core package to maintain a clean, unidirectional dependency flow.

Cache the most commonly used query parameter names for positional parameters to prevent
the creation of new strings for every single SQL statement execution.
@olavloite
olavloite force-pushed the spanner-cache-common-param-names branch from e7ff741 to d4616c8 Compare August 11, 2026 14:09
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a caching mechanism for positional parameter names (e.g., "p1", "p2") up to index 256 in Statement.java to avoid repetitive string concatenation, updating references across JDBC and parser classes to use this new utility. The review feedback suggests defining a constant for the cache size instead of using magic numbers to improve code maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant