Skip to content

feat(engine): prepared-statement plan cache + parameter binding (SQLR…#110

Merged
joaoh82 merged 1 commit into
mainfrom
feat/sqlr-23-prepare-cache-bind
May 8, 2026
Merged

feat(engine): prepared-statement plan cache + parameter binding (SQLR…#110
joaoh82 merged 1 commit into
mainfrom
feat/sqlr-23-prepare-cache-bind

Conversation

@joaoh82

@joaoh82 joaoh82 commented May 8, 2026

Copy link
Copy Markdown
Owner

…-23)

Connection::prepare_cached (default 16-entry per-connection LRU) + Statement::query_with_params / Statement::execute_with_params substitute ? placeholders into a cached AST at execute time, skipping the per-call sqlparser walk. Value::Vector(Vec<f32>) is a first-class bind type — a bound vector substitutes into the same in-band bracket- array shape an inline […] literal would, so the HNSW probe optimizer still recognizes it on prepared queries.

Bench harness flipped from per-call SQL formatting (inline_params) to the bound + cached path; every workload's WorkloadId.version bumped v1 → v2 in lockstep so the methodology change is captured explicitly. Old v1 envelopes stay readable; the comparison script flags cross- version pairs.

Smoke run confirms parser-bound wins on the workloads the plan predicted: W1 -52%, W6 -61%, W3 -44%, W11 -26%. Republishing the official pinned-host envelope is SQLR-25.

Surfaced one pre-existing limitation: try_hnsw_probe is L2-only, so W10's vec_distance_cosine query has been silently brute-forcing the HNSW variant the entire time. SQLR-28 tracks widening the probe to cosine + dot.

…-23)

`Connection::prepare_cached` (default 16-entry per-connection LRU) +
`Statement::query_with_params` / `Statement::execute_with_params`
substitute `?` placeholders into a cached AST at execute time, skipping
the per-call sqlparser walk. `Value::Vector(Vec<f32>)` is a first-class
bind type — a bound vector substitutes into the same in-band bracket-
array shape an inline `[…]` literal would, so the HNSW probe optimizer
still recognizes it on prepared queries.

Bench harness flipped from per-call SQL formatting (`inline_params`) to
the bound + cached path; every workload's `WorkloadId.version` bumped
`v1 → v2` in lockstep so the methodology change is captured explicitly.
Old v1 envelopes stay readable; the comparison script flags cross-
version pairs.

Smoke run confirms parser-bound wins on the workloads the plan
predicted: W1 -52%, W6 -61%, W3 -44%, W11 -26%. Republishing the
official pinned-host envelope is SQLR-25.

Surfaced one pre-existing limitation: `try_hnsw_probe` is L2-only, so
W10's `vec_distance_cosine` query has been silently brute-forcing the
HNSW variant the entire time. SQLR-28 tracks widening the probe to
cosine + dot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaoh82 joaoh82 merged commit 1e22ac4 into main May 8, 2026
30 of 31 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.

1 participant