Repository navigation
Keep only text and BLOB values in a statement's bound parameters - #393
Merged
Merged
Conversation
`bind!` stored every bound value in `stmt.params`, a `Dict{Int,Any}`
that keeps values alive while SQLite reads them. SQLite copies numbers
and NULLs when they are bound, so storing them only boxed each value and
hashed it into the Dict, once per value in every `load!`, `execute`, and
`executemany` call.
Numeric, Bool, `missing`, and `nothing` values are no longer stored.
Text and BLOB values, which SQLite reads in place, still are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #393 +/- ##
==========================================
- Coverage 97.30% 97.28% -0.02%
==========================================
Files 5 5
Lines 854 848 -6
==========================================
- Hits 831 825 -6
Misses 23 23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Why
Every
bind!call stored its value instmt.params, aDict{Int,Any}that keeps bound values alive while SQLite reads them. SQLite copies numbers and NULLs when they are bound, so for those values the store only boxed the value and hashed it into the Dict. That cost lands on every value inload!,execute, andexecutemany.What changed
bind!no longer stores numbers,Bool,missing, ornothinginstmt.params. Text and BLOB values, which SQLite reads in place, are still stored.Scope
Blast Radius
Every bound parameter. When a parameter that held text is rebound to a number,
stmt.paramskeeps the old text until that parameter gets text or a BLOB again,clear!runs, or the statement is freed. Before, the number replaced it. At most one stale value per parameter stays alive.Verification
load!of a mixed 10-column table with 1M rows went from 658 ms to 561 ms (2237 to 1972 million cycles).executemanyof the same rows went from 2670 ms to 2458 ms. A prepared one-row query on an in-memory database used 6% fewer cycles (404 to 380 million per 100k queries). Each number is the median of 7 fresh-process runs per side, interleaved with master, on a shared 14-core Apple silicon machine (load average 10 to 50).Pkg.test()passes on Julia 1.12 and 1.10, and the trim workload (test/trim) builds and runs on Julia 1.13.🤖 Generated with Claude Code