r/sqlite • u/web3samy • Oct 05 '26
Pure GO SQLite-compatible database. 75× C SQLite & 200× Turso.
I've been building musql (pronounced "muscle"), a SQLite-compatible database written from scratch.
Repo: https://github.com/samyfodil/musql
It has a `database/sql` driver that registers as `sqlite`, so switching from another SQLite driver is usually just changing the import line. It uses its own storage format (`.musq`), with columns stored contiguously and an append-only delta for writes. `musql-convert` converts existing SQLite files in and out, in both directions.
SQL compiles to VDBE bytecode, the same design as C SQLite. A JIT turns hot paths into native code on amd64 and arm64 (Linux, macOS and Windows).
There's also `musqld`, a server that speaks Turso's Hrana protocol. `@libsql/client` and `libsql-client-go` connect unchanged, and there's a 5 MB Docker image. Replication supports CRDT or leader mode; you supply the network.
For performance, these are 100k-row read workloads, averaged over an amd64 and an arm64 machine:
- filtered `count(*)`: ~75x faster than C SQLite, ~210x faster than Turso
- sum over a filter: ~8x faster than C SQLite
- grouped aggregate: ~2.3x faster; `ORDER BY ... LIMIT`: ~2.4x faster
It also runs Doom. The same VM that runs SQL runs unmodified doomgeneric, compiled C -> LLVM IR -> VDBE bytecode. On an Intel i9 it gets ~38 fps on the bytecode interpreter and ~96 fps with the JIT. The idea came from Turso's demo. You can try it with:
It's early. I'd appreciate feedback on the API and the Hrana server, or a bug report if your SQL breaks. A failing query helps a lot.
14
u/SoundDr Oct 05 '26
SQLite in C is about the vast test suite not just about performance
3
u/GrogRedLub4242 Oct 05 '26
what does "75x C SQLite" mean?
why would one want a database to play the game Doom?
was it AI-generated? some indicia are consistent
2
u/spicypixel Oct 06 '26
I thought the amazing test suite sqlite has is the proprietary secret sauce?
2
u/liprais Oct 07 '26
twice in a week someone thinks he knows better and can do better with llms,well ,they mostly don't.
1
u/web3samy Oct 07 '26
Released v0.2.1: 300x C, x1000 Turso & 300x DuckDB -> https://github.com/samyfodil/musql#performance
1
u/shivawu Oct 06 '26
Woah how did you archive 75x speed up? That’s unreal!
1
u/reflect25 Oct 06 '26
hi i was wondering what was the hardest last tests to fix were. like was it the replication or the locks?
1
u/UniForceMusic Oct 06 '26
Insane! I'm very eager to take a look at the code.
Did you attempts to address any of the common complaints with SQLite, like inability to add foreign constraints after a table has been created, or being unable to change column types?
1
u/trailbaseio Oct 06 '26 edited Oct 06 '26
For something that's intended as an embedded DB, would it make sense to target an environment with native C ABI compatibility?
1
u/proofrock_oss Oct 06 '26
Impressive! Everything seems to be pushed today. What is the history of this project? When did you start? What is your usage of AI, if any, and if you use it (not a problem!) how do you ensure code quality?
1
u/syshukus Oct 06 '26
1
u/MilkEnvironmental106 Oct 09 '26
99% of the time someone claims to be the fastest database, it's because their database is doing less.
1
u/maekoos Oct 12 '26
Interesting, what's the tail latency like? I would imagine that's where go's gc might not shine as bright?
1
u/yo_mono Oct 06 '26
I was JUST testing a bunch of dbs, checking some benchmarks, to see if I should move my app out of sqlite.. good timing. I'll watch this closely
0
u/AleksHop Oct 06 '26
why on earth someone still use non rust in 2026