Learning a few things about running SQLite

281 points · 75 comments on HN · read original →

Points and comments are a snapshot, not live.

Running SQLite in production requires more operational care than simple blog posts suggest.

The author details running SQLite for a Django site, learning that ANALYZE dramatically sped up a 5-second FTS5 query on 4000 rows to near-instant. Cleanup operations (e.g., DELETE) can time out on 5-second write locks, leading to worker crashes, so they batch them. Backups use restic with VACUUM INTO or litestream for incremental replication. They previously split tables across three database files for Mess with DNS, which has run on SQLite for four years.

What commenters are saying

Commenters offered practical advice. Several pointed to SQLite's `.expert` mode for index recommendations, and noted that EXPLAIN QUERY PLAN is more readable than raw bytecode. Multiple commenters emphasized that batching large deletes/updates is standard for all databases, not just SQLite. One highlighted `s3-credentials` for scoped AWS keys. Another noted that reading value distributions from `sqlite_stat1` and `sqlite_stat4` is what ANALYZE stores. A few debated whether SQLite is suitable for networked or high-concurrency systems.