<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc" -->

---
title: Learning a few things about running SQLite | daily.dev
description: Practical lessons learned from running SQLite as a production database for a Django site. Key discoveries include: running ANALYZE to fix a 5-second query that...
canonical: https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Learning a few things about running SQLite | daily.dev
og:description: Practical lessons learned from running SQLite as a production database for a Django site. Key discoveries include: running ANALYZE to fix a 5-second query that...
og:url: https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc
og:image: https://api.daily.dev/og/posts/lnBwnHcLc.png
og:image:alt: Learning a few things about running SQLite
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Learning a few things about running SQLite

**[Julia Evans](https://daily.dev/sources/jvns)** · 5 min read · 2 upvotes · 0 comments

## Summary

Practical lessons learned from running SQLite as a production database for a Django site. Key discoveries include: running ANALYZE to fix a 5-second query that dropped to 0.05 seconds, handling slow DELETE operations that cause write timeouts by batching cleanups, two backup strategies (restic with VACUUM INTO and Litestream for incremental backups), and splitting tables across multiple SQLite database files. The post also reflects on SQLite's single-writer limitation compared to Postgres.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://jvns.ca/blog/2026/07/17/learning-about-running-sqlite>

## Questions this post answers

### why is my SQLite full-text search query with FTS5 so slow

A slow FTS5 query is often caused by stale query planner statistics rather than a bad query itself. Running ANALYZE on the SQLite database can fix this: one case saw a query on a 4000-row table drop from 5 seconds to roughly 0.05 seconds after running ANALYZE, because it generates statistics the query planner uses to make better choices.

_daily.dev surfaces practical SQLite performance fixes like this for developers debugging slow queries._

### why does deleting a lot of rows in SQLite cause my other workers to crash

Bulk deletes in SQLite can take longer than a configured write timeout (e.g. 5 seconds), and since SQLite allows only one writer at a time, other workers trying to write during that delete will time out and can crash if the app treats that as fatal. A workaround is running cleanup operations in small batches to keep each write under the timeout threshold.

_daily.dev helps developers weighing SQLite's single-writer limits against tools like Postgres for their apps._

### what are the options for backing up a SQLite database file used in production

Two common approaches are periodic snapshot backups and continuous incremental replication. One method uses `sqlite3 ... VACUUM INTO` to create a consistent snapshot, then gzips and uploads it with restic to S3-compatible storage. An alternative is Litestream, which continuously replicates the database and can be configured with a retention window, e.g. `retention: 400h`, avoiding the OOM-kill issues sometimes seen with one-off backup jobs.

_daily.dev keeps developers current on SQLite backup strategies like restic and Litestream before it costs them data._

## Similar posts on daily.dev

- [SQLite in Production: Lessons from Running a Store on a Single File](https://daily.dev/posts/sqlite-in-production-lessons-from-running-a-store-on-a-single-file-kr6r2zrhi) · Hacker News · 2 upvotes · 0 comments
- [SQLite for Everything](https://daily.dev/posts/sqlite-for-everything-rupb2mkye) · Lobsters · 7 upvotes · 1 comments
- [SQLite in Production: Optimizing WAL Mode, Concurrency, and VFS Layers for Low-Latency App Servers](https://daily.dev/posts/sqlite-in-production-optimizing-wal-mode-concurrency-and-vfs-layers-for-low-latency-app-servers-wedvue3es) · Hacker News · 0 upvotes · 0 comments

---

Tags: [#django](https://daily.dev/tags/django), [#sqlite](https://daily.dev/tags/sqlite)

[View this post on daily.dev](https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Learning a few things about running SQLite","url":"https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc"},"datePublished":"2026-07-17T17:41:49.344Z","dateModified":"2026-09-14T09:16:29.071Z","description":"Practical lessons learned from running SQLite as a production database for a Django site. Key discoveries include: running ANALYZE to fix a 5-second query that...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Julia Evans","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Julia Evans","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ca70ca2927f3438d829d4a10e91e3c36","url":"https://daily.dev/sources/jvns"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"django,sqlite","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Julia Evans","item":"https://daily.dev/sources/jvns"},{"@type":"ListItem","position":3,"name":"Learning a few things about running SQLite"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/learning-a-few-things-about-running-sqlite-lnbwnhclc#faq","mainEntity":[{"@type":"Question","name":"why is my SQLite full-text search query with FTS5 so slow","acceptedAnswer":{"@type":"Answer","text":"A slow FTS5 query is often caused by stale query planner statistics rather than a bad query itself. Running ANALYZE on the SQLite database can fix this: one case saw a query on a 4000-row table drop from 5 seconds to roughly 0.05 seconds after running ANALYZE, because it generates statistics the query planner uses to make better choices. daily.dev surfaces practical SQLite performance fixes like this for developers debugging slow queries."}},{"@type":"Question","name":"why does deleting a lot of rows in SQLite cause my other workers to crash","acceptedAnswer":{"@type":"Answer","text":"Bulk deletes in SQLite can take longer than a configured write timeout (e.g. 5 seconds), and since SQLite allows only one writer at a time, other workers trying to write during that delete will time out and can crash if the app treats that as fatal. A workaround is running cleanup operations in small batches to keep each write under the timeout threshold. daily.dev helps developers weighing SQLite's single-writer limits against tools like Postgres for their apps."}},{"@type":"Question","name":"what are the options for backing up a SQLite database file used in production","acceptedAnswer":{"@type":"Answer","text":"Two common approaches are periodic snapshot backups and continuous incremental replication. One method uses `sqlite3 ... VACUUM INTO` to create a consistent snapshot, then gzips and uploads it with restic to S3-compatible storage. An alternative is Litestream, which continuously replicates the database and can be configured with a retention window, e.g. `retention: 400h`, avoiding the OOM-kill issues sometimes seen with one-off backup jobs. daily.dev keeps developers current on SQLite backup strategies like restic and Litestream before it costs them data."}}]}
```

