Repository navigation
Read strict query rows without dispatching on each column type - #391
Merged
Merged
Conversation
Reading a strict query row by index or by name (`row.x`,
`Tables.getcolumn(row, i)`) called `getvalue` with the column's runtime
`Union` type. Julia's fast dispatch cache can't hold such calls, so every
value took about 0.5 µs to find its method. Iterating 1M rows of one
INTEGER column with `strict=true` took about 860 ms, against 160 ms
without `strict`.
`getcolumn` now compares the column type with the types that declared
column types and raw BLOBs give (Int64, Float64, String, Vector{UInt8},
and Any) and calls `getvalue` statically for those. Other types, such as
deserialized Julia values, still dispatch at run time. Column tables and
other schema-based sinks already called `getvalue` statically.
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 #391 +/- ##
==========================================
+ Coverage 97.30% 97.33% +0.02%
==========================================
Files 5 5
Lines 854 862 +8
==========================================
+ Hits 831 839 +8
Misses 23 23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A Date column takes the runtime-dispatched read in getcolumn, the path for column types other than the ones it reads statically. Co-Authored-By: Claude Opus 5.5 <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.
Why
People who loop over a strict query (
DBInterface.execute(db, sql; strict=true)) and readrow.xorTables.getcolumn(row, i)paid for a method-cache search on every value. Each read dispatched on the column's runtimeUniontype, which Julia's fast dispatch cache can't hold. Strict row loops ran 3-5x slower than non-strict ones.What changed
Tables.getcolumn(row, i)callsgetvaluestatically forInt64,Float64,String,Vector{UInt8}, andAnycolumns. Those are the types that declared column types and raw BLOBs give. Other column types, such as deserialized Julia values, still dispatch at run time.Scope
columntable,DataFrame, and other schema-based sinks already read statically, so they don't change.Blast Radius
Only strict row reads. The static calls reach the same
getvaluemethods the dynamic call found, so values and errors don't change.Verification
Pkg.test()passes on Julia 1.12 and 1.10.ijl_apply_genericandjl_typemap_assoc_exactundergetcolumn(r::Row, i).🤖 Generated with Claude Code