Add prepared plans option to bench database tests#1815
Merged
Conversation
Contributor
ApprovabilityVerdict: Approved Test infrastructure change that adds prepared query support to database benchmarks. All changes are in benchmark test files and auto-generated sqlc code, with no impact on production runtime. The author owns all modified files. You can customize Macroscope's approvability policy. Learn more. |
mkysel
approved these changes
Mar 16, 2026
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.
TLDR
Total benchmarks: 25
Consistent gains: 13
Consistent regressions: 3
Mixed/noisy: 9
Consistent gains
BenchmarkSelectGatewayEnvelopesByTopics/rows=1M-14 (avg ~-30.8%)
BenchmarkSelectGatewayEnvelopesBySingleOriginator/rows=1M-14 (avg ~-23.6%)
BenchmarkInsertGatewayEnvelopeBatch/rows=1M-14 (avg ~-20.8%)
BenchmarkGetLastEvent-14 (avg ~-14.9%)
BenchmarkIncrementUnsettledUsage-14 (avg ~-12.6%)
BenchmarkHotPathFullCycle-14 (avg ~-12.5%)
BenchmarkHotPathSelectStaged-14 (avg ~-11.9%)
BenchmarkHotPathInsertStaged-14 (avg ~-9.5%)
BenchmarkHotPathDeleteStaged-14 (avg ~-8.0%)
BenchmarkSelectGatewayEnvelopesUnfiltered/rows=1M-14 (avg ~-7.7%)
BenchmarkSelectNewestFromTopics/rows=1M-14 (avg ~-7.4%)
BenchmarkSelectGatewayEnvelopesByOriginators/rows=1M-14 (avg ~-7.4%)
BenchmarkGetRecentOriginatorCongestion-14 (avg ~-6.9%)
Consistent regressions
BenchmarkHotPathBatchCycle/batch=100-14 (avg ~+26.2%)
BenchmarkHotPathBatchCycle/batch=1-14 (avg ~+9.9%)
BenchmarkInsertPayerLedgerEvent-14 (avg ~+44.0%, but driven by a large outlier in POST4)
Mixed/noisy
BenchmarkSetLatestBlock-14
BenchmarkSumOriginatorCongestion-14
BenchmarkGetPayerBalance-14
BenchmarkIncrementOriginatorCongestion-14
BenchmarkInsertGatewayEnvelope/rows=1M-14
BenchmarkHotPathBatchCycle/batch=10-14
BenchmarkHotPathInsertGatewayWithUsage-14
BenchmarkHotPathBatchCycle/batch=500-14
BenchmarkGetLatestBlock-14
Note
Add prepared query support to database benchmarks via
BENCH_USE_PREPAREDflagsqlcprepared query emission (emit_prepared_queries: true) and generatesPrepare,Close, and routing helpers (exec,query,queryRow) inpkg/db/queries/db.go.BENCH_USE_PREPAREDenv var (defaulttrue) todev/benchandpkg/db/bench/main_test.goto toggle prepared statements at benchmark runtime.*queries.Queriesinstances (e.g.congestionQueries,hotPathQueries) instead of constructing local query objects per benchmark.BENCH_USE_PREPARED=falseto revert to unprepared queries.Macroscope summarized 4c40719.