Skip to content

Reduce sqlite bind overhead#1385

Merged
mattn merged 1 commit into
masterfrom
perf/reduce-bind-overhead
Apr 6, 2026
Merged

Reduce sqlite bind overhead#1385
mattn merged 1 commit into
masterfrom
perf/reduce-bind-overhead

Conversation

@mattn

@mattn mattn commented Apr 6, 2026

Copy link
Copy Markdown
Owner

This change reduces overhead in the statement binding path.

It removes redundant bind logic, avoids an extra string-to-byte-slice copy when binding text values, and caches named parameter index lookups per prepared statement.

The main effect is lower overhead on parameterized execution paths, especially for repeated statement use and named parameters.

Validation was done with:

  • go test ./...
  • go test -run ^ -bench 'BenchmarkSuite/(BenchmarkExec|BenchmarkQuery|BenchmarkParams|BenchmarkStmt|BenchmarkQueryParallel)$' -benchmem -benchtime=200ms
Benchmark Before After Change Improvement
BenchmarkExec 3580 ns/op 3499 ns/op -81 ns/op 2.3%
BenchmarkQuery 8418 ns/op 8395 ns/op -23 ns/op 0.3%
BenchmarkParams 9084 ns/op 8835 ns/op -249 ns/op 2.7%
BenchmarkStmt 5864 ns/op 5858 ns/op -6 ns/op 0.1%
BenchmarkQueryParallel 3169 ns/op 3139 ns/op -30 ns/op 0.9%

@mattn mattn marked this pull request as ready for review April 6, 2026 12:31
@mattn mattn merged commit 4a311ff into master Apr 6, 2026
20 checks passed
@mattn mattn deleted the perf/reduce-bind-overhead branch April 6, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant