SNKV cuts the top three layers and talks directly to SQLite's B-tree engine. No SQL strings. No query planner. No VM. Just put/get/delete on the same storage core that powers SQLite.
Python:
pip install snkv
from snkv import KVStore
with KVStore("mydb.db") as db:
db["hello"] = "world"
print(db["hello"]) # b"world"
C/C++ (single-header, drop-in): #define SNKV_IMPLEMENTATION
#include "snkv.h"
KVStore *db;
kvstore_open("mydb.db", &db, KVSTORE_JOURNAL_WAL);
kvstore_put(db, "key", 3, "value", 5);
Benchmarks vs SQLite WITHOUT ROWID (1M records, identical settings): Sequential writes +57%
Random reads +68%
Sequential scan +90%
Random updates +72%
Random deletes +104%
Exists checks +75%
Mixed workload +84%
Bulk insert +10%
Honest tradeoffs:
- LMDB beats it on raw reads (memory-mapped)
- RocksDB beats it on write-heavy workloads (LSM-tree)
- sqlite3 CLI won't open the database (schema layer is bypassed by design)What you get: ACID, WAL concurrency, column families, crash safety — with less overhead for read-heavy KV workloads.
Retr0id•1h ago
I've considered building this exact thing before (I think I've talked about it on HN even), but the reason I didn't build it was because I was sure (on an intuitive level) the actual overhead of the SQL layer was negligible for simple k/v queries.
Where does the +104% on random deletes (for example) actually come from?
swaminarayan•1h ago
The SQL layer overhead alone is probably small, you're right. The bigger gain comes from a cached read cursor. SQLite opens and closes a cursor on every operation. SNKV keeps one persistent cursor per column family sitting open on the B-tree. On random deletes that means seek + delete on an already warm cursor vs. initialize cursor + seek + delete + close on every call.
For deletes there's also prepared statement overhead in SQLite — even with prepare/bind/step/reset, that's extra work SNKV just doesn't do.
I'd genuinely like someone else to run the numbers. Benchmark source is in the repo if you want to poke at it — tests/test_benchmark.c on the SNKV side and https://github.com/hash-anu/sqllite-benchmark-kv for SQLite. If your results differ I want to know.
Retr0id•1h ago
swaminarayan•1h ago
bflesch•1h ago
swaminarayan•40m ago
d1l•1h ago
derwiki•1h ago
altmanaltman•1h ago
d1l•1h ago
swaminarayan•39m ago
nightfly•1h ago
snowhale•48m ago
swaminarayan•15m ago