r/sqlite • u/Fabulous-Cookie-6457 • 3d ago
How a read buffer changes the result of a 100-migration SQLite benchmark in Go
I maintain Go-Gen-Ecosystem/go-migrate. I compared v1.0.1 with golang-migrate/migrate v4.20.1 and pressly/goose v3.30.1. Each library applied the same 100 SQL migrations to a fresh SQLite database. Each migration created a table and inserted one row.
On Linux/amd64 with Go 1.26.11, the median allocated per batch across six samples was 727.8 KiB for go-migrate, 10.66 MiB for golang-migrate, and 1.14 MiB for goose. Goose made the fewest allocations at default settings, with 8,547 per batch compared with 9,420 for golang-migrate and 10,873.5 for go-migrate.
I repeated the golang-migrate benchmark with one change. Setting gm.DefaultBufferSize = 4096 at the start of its benchmark, down from the 100,000-byte default, brought its median to 892.2 KiB on these small files. All three libraries used in-memory migration sources, the same pure-Go SQLite driver, WAL, and synchronous=OFF.
To reproduce the defaults from a disposable v1.0.1 checkout, run the following. The tagged benchmark module needs -mod=mod to refresh its dependency metadata.
GOWORK=off CGO_ENABLED=0 GOTOOLCHAIN=go1.26.11
1
u/missinglinknz 3d ago
I’m not clear what you’re asking here exactly, is it why the db filesize differs when changing the buffer size?
What happens if you run VACUUM on these databases? I would expect the numbers to be very similar/same afterwards.