Repository navigation
IGNITE-29331 SQL Calcite: Do not build a digest of expressions on every execution of a cached plan - #13868
Merged
Conversation
…ry execution of a cached plan
Contributor
Author
|
/runall |
|
@NSAmelchev ✅ No blockers · full verdict RunAll 9517908 · 04ca279 · glossary ♻️ Settled after 2 auto re-run waves: #1 — 1 suite that failed mid-run; #2 — 1 broken suite. |
zstan
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ExpressionFactoryImplcaches compiled expressions by a string digest. The digest is built from the expression treeon every request: an index scan by a primary key requests four expressions (project, filter, lower and upper
bounds), so every execution builds four strings, hashes them and compares them with the cached keys.
Fix
One more cache is checked first. Its key is the expressions themselves, compared by identity, together with the row
type and the kind of the scalar. A cached plan passes the same expression instances on every execution, so the
digest is built only on a miss, and then the existing cache is used as before.
Expressions are compared by identity on purpose: equal expressions can differ in details the digest takes into
account (see IGNITE-18282 and IGNITE-23435).
The new cache is bounded by 1024 entries, like the existing one, and keeps references to the expressions, including
the ones of plans already evicted from the plan cache.
Benchmark
JMH, one embedded server node, 1024 partitions, table
KV (ID INT PRIMARY KEY, VAL VARCHAR)with 100,000 rows,1 thread, ARM (Apple Silicon), OpenJDK 17.
SELECT VAL FROM KV WHERE ID = ?UPDATE KV SET VAL = ? WHERE ID = ?