Skip to content

IGNITE-29331 SQL Calcite: Do not build a digest of expressions on every execution of a cached plan - #13868

Merged
NSAmelchev merged 1 commit into
apache:masterfrom
NSAmelchev:ignite-29331
Nov 23, 2026
Merged

NSAmelchev merged 1 commit into
apache:masterfrom
NSAmelchev:ignite-29331

Conversation

@NSAmelchev

Copy link
Copy Markdown
Contributor

Problem

ExpressionFactoryImpl caches compiled expressions by a string digest. The digest is built from the expression tree
on 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.

Query master, ops/s PR, ops/s Diff master, B/op PR, B/op Diff
SELECT VAL FROM KV WHERE ID = ? 38,038 38,626 +1.5 % 39,982 37,432 -6.4 %
UPDATE KV SET VAL = ? WHERE ID = ? 27,948 29,185 +4.4 % 53,591 48,699 -9.1 %

@NSAmelchev

Copy link
Copy Markdown
Contributor Author

/runall

@ignite-pr-checker

Copy link
Copy Markdown

@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.

@NSAmelchev
NSAmelchev merged commit 138ce5e into apache:master Nov 23, 2026
6 checks passed
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.

3 participants