Repository navigation
Reduce allocations when decoding scalar and numeric results - #18
Merged
Merged
Conversation
This was referenced Sep 26, 2026
quinnj
referenced
this pull request
Sep 28, 2026
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.
Postgres copies every non-null result field into a String before decoding it, and numeric values additionally pass through BigInt. This makes ordinary numeric queries allocate heavily even when their values fit the supported decimal type.
Decode fixed-width integers, floats, and booleans directly from bounded row-buffer views. Reuse DataDecimals' exact native parser for short fixed-point decimals with Parsers 3. The existing fallback preserves long coefficients, trailing-zero scale, exponent limits, special values, overflow policy, and Parsers 2 compatibility. Retained text, lazy JSON, and custom parsers still receive owned strings. Typed results retain custom style lifts and exact fixed-scale conversion.
Warmed, matched measurements on Julia 1.13.0 / PostgreSQL 16.15 (local arm64 server), 10,000-row prepared queries:
Numeric queries are about 3.4× faster with 88–90% fewer allocated bytes. Typed nondecimal query timing is effectively unchanged. The included
benchmark/decoding.jlalso measures decoder-only workloads and JSON/array controls; it reports timing spread and allocation counts separately from whole-query measurements.Validation:
--trim=safeattempts have the same 20 existing verifier errors before and after: typed StructUtils calls through the dynamic type registry and default interval construction. This PR does not claim to make the driver trimmable. No protocol, buffering, dependency, export, or public API change is included.Combined validation: the published SASLAuth #6 and #7 sources pass all 690 package checks together on Julia 1.9.4 and 1.13.0. Using that combined authentication source with the published Postgres #18 and #19 sources passes the full local integration suite: 8,375 checks on Julia 1.13.0 and 8,349 on 1.10.11. Production patches apply unchanged; only overlapping test-runner includes needed composition in the temporary fixture. Dependency versions and source hashes were verified. This adds compatibility evidence, not a new timing or native-compilation claim.
Co-authored by Codex