SQLite in Production: Lessons from Four Years of Running It

TL;DR
SQLite in production lessons from Julia Evans: the ANALYZE fix that cut a query 100x, batching writes around the single writer, and backups that work.
Last updated: July 18, 2026
Julia Evans just published a fantastic piece on running SQLite in production for her Mess With DNS project, and it hit the front page of Hacker News with over 270 points and a rich discussion. After four years of production use, she's distilled the real operational challenges you won't find in getting-started tutorials.
The 100x Query Speedup You Might Be Missing#
The most striking discovery: running ANALYZE dropped a full-text search query from 5 seconds to 0.05 seconds. That's a 100x improvement from a single command.
SQLite's query planner makes decisions based on table statistics stored in sqlite_stat1 and sqlite_stat4. Without running ANALYZE, those statistics don't exist - and the planner can choose disastrously bad query plans.
In Julia's case, a query on a 4,000-row table was likely hitting an accidentally quadratic plan. The fix was simple:
ANALYZE;
The lesson: if you're seeing unexpected slow queries on tables with indexes, run ANALYZE before reaching for more complex solutions.
What HN Is Saying#
The Hacker News discussion surfaced several additional insights from battle-tested SQLite users:
On query plans and the .expert command: Multiple commenters pointed to SQLite's .expert mode as a way to avoid learning query plan syntax entirely. It analyzes your queries and suggests indexes:
sqlite> .expert
sqlite> SELECT * FROM x1 WHERE a=? AND b>?;
CREATE INDEX x1_idx_000123a7 ON x1(a, b);
On batching large operations: One commenter noted that even "real" databases like MySQL require batching large DELETE or UPDATE operations. The advice to batch cleanup operations in SQLite isn't a limitation - it's universal database wisdom. Row-based replication in MySQL can choke on a million-row UPDATE just as badly.
On backup approaches: Simon Willison shared his s3-credentials tool for generating scoped AWS credentials - solving the same "annoying to navigate AWS console" pain Julia mentioned. Others suggested Cloudflare R2 as an S3-compatible alternative with simpler pricing.
One user shared a particularly elegant backup approach:
sqlite3 -readonly "${db}" .dump | zstd --fast --rsyncable -o "${db}.sql.zst"
This produces a compressed dump that's also sync-friendly - because --rsyncable structures the compression so unchanged portions of the file stay byte-identical, tools like borg or restic only transfer what actually changed.
The Write Contention Problem#
SQLite allows only one writer at a time. Julia hit this when running cleanup jobs - deleting large batches of rows caused other workers to timeout after 5 seconds and crash.
The solution was straightforward: batch deletions into smaller operations. Instead of DELETE FROM table WHERE condition affecting thousands of rows, she runs smaller batches that complete within the write timeout.
This isn't unique to SQLite. As one commenter noted: "Anyone that's done significant database work has come to the understanding that large updates need to be done in batches, otherwise you nuke performance. Once you get to about 1M rows of data, batching is essential."
Backup Strategies That Actually Work#
Julia outlined two main approaches:
Restic + VACUUM INTO: Create a complete copy of the database, compress it, send to S3. The downside: occasional out-of-memory failures on larger databases.
Litestream: Incremental backup that streams WAL changes continuously. Julia runs it with retention: 400h for historical preservation.
The key insight: neither approach alone is sufficient. You need monitoring - a "dead man's switch" that alerts if a backup hasn't succeeded within a configured window. Backup jobs can fail silently, hang forever, or crash in ways that don't trigger alerts.
When SQLite Isn't Enough#
Julia's honest about the limits: "This whole experience has given me more of an appreciation for why someone might want to use a 'real' database like Postgres which can have more than one writer at the same time."
For her use case - a read-heavy project with ~10,000 rows and a single primary writer - SQLite works well. But the single-writer limitation becomes painful when you need concurrent write operations or have workers that might step on each other.
Multiple Databases Are Fine#
One underappreciated pattern: you can split data across multiple SQLite files. Julia uses this for the Mess With DNS project, keeping separate databases for tables that don't need referential integrity between them.
SQLite can even query across files in a single statement using ATTACH DATABASE. This lets you shard by natural boundaries (per-user data, logs vs. core data) while keeping the operational simplicity of SQLite.
The Developer Experience Win#
What makes SQLite compelling isn't just performance - it's the operational simplicity. No server process to manage. No network configuration. Backups are just file copies (with the right precautions). Your database is debuggable with standard Unix tools.
As Julia puts it, Mess With DNS "has been running on SQLite for 4 years" successfully. For stable, read-heavy workloads without complex concurrent write patterns, that's a strong endorsement.
Key Takeaways#
- Run ANALYZE after your database has representative data - the query planner needs statistics
- Batch large write operations to avoid hitting the write timeout
- Use
.expertmode for index recommendations instead of reading query plans - Monitor your backups with dead man's switches, not just failure alerts
- Consider multiple databases when tables don't need cross-references
- Know when to graduate - concurrent writes are SQLite's limit
The full post has more detail on the specific issues Julia encountered with each approach. If you're running SQLite in production or considering it, it's worth the read.
FAQ#
Why does running ANALYZE speed up SQLite queries?#
SQLite's query planner relies on table statistics stored in sqlite_stat1 and sqlite_stat4. Without ANALYZE, those statistics do not exist and the planner can pick very bad query plans. In Julia Evans' case, running ANALYZE cut a full-text search query from 5 seconds to 0.05 seconds.
How do you avoid write contention in SQLite?#
SQLite allows only one writer at a time, so large deletes can make other workers time out. Julia's fix was to batch deletions into smaller operations that finish within the write timeout, which commenters noted is standard practice for large updates in any database.
What is the best way to back up a SQLite database in production?#
Julia uses two approaches: restic with VACUUM INTO for full compressed copies sent to S3, and Litestream for continuous WAL streaming. Neither is enough alone without monitoring, such as a dead man's switch that alerts when a backup has not succeeded within a set window.
When should you switch from SQLite to Postgres?#
When you need concurrent writes. SQLite works well for read-heavy workloads with a single primary writer, but Julia notes the experience gave her more appreciation for databases like Postgres that can have more than one writer at the same time.
Continue Reading#
- DuckDB Internals: What Makes It So Fast
- GitHub Case-Folds 480TB of Code at >45 GiB/s: The Branchless Casefold Crate
- Is Claude Fable 5 Slow? Latency in Practice, and When It Matters
- SQLite STRICT Tables: Why Type Safety Should Be Your Default
Sources#
- Learning a few things about running SQLite - Julia Evans' original post
- Hacker News discussion - 73+ comments with additional production tips
- SQLite .expert mode documentation - Index recommendation feature
- SQLite ANALYZE documentation - Statistics collection command
Get the next deep dive like this in your inbox
One email a week on News and the rest of the AI dev stack. Free.
Read next
DuckDB Internals: What Makes It So Fast
DuckDB internals explained: columnar storage, vectorized execution and an in-process design that let it rival costly clusters on a laptop, plus what HN says.
8 min readThe Startup's Postgres Survival Guide: What HN Is Saying About Hatchet's Battle-Tested Advice
The startup Postgres survival guide from Hatchet, plus the HN pushback on monitoring, backups, and cascades, and what to internalize for production Postgres.
5 min readSQLite STRICT Tables: Why Type Safety Should Be Your Default
SQLite's flexible typing lets you store anything anywhere. STRICT mode fixes that - here's why you should enable it for every new table.
6 min readNew here? Start with
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.





