feat(engine): prepared-statement plan cache + parameter binding (SQLR…#110
Merged
Conversation
…-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>
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.
…-23)
Connection::prepare_cached(default 16-entry per-connection LRU) +Statement::query_with_params/Statement::execute_with_paramssubstitute?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'sWorkloadId.versionbumpedv1 → v2in 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_probeis L2-only, so W10'svec_distance_cosinequery has been silently brute-forcing the HNSW variant the entire time. SQLR-28 tracks widening the probe to cosine + dot.