首页›Julia Evans›文章

Learning a few things about running SQLite

Julia Evans · 2026年7月17日

AI 摘要 AI 生成,可能有误

作者分享了在 Django 网站上使用 SQLite 作为数据库所获得的经验教训,包括运行 ANALYZE 如何大幅提速了缓慢的全文搜索查询,以及由于 SQLite 同一时间只允许一个写入者,长时间运行的清理 DELETE 操作如何导致其他 worker 超时并崩溃。他们还介绍了使用 restic 和 Litestream 进行备份的方法,以及将表拆分到多个数据库文件等技巧。尽管存在这些挑战,他们发现 SQLite 对于小型网站来说运行良好,不过这段经历也让他们更加体会到 Postgres 这类数据库的价值。

Hello! I’ve been working on a Django site recently, and I decided to use SQLite as the database. When I was getting started with using SQLite as database for a website I read a bunch of blog posts about how it is totally fine to use SQLite in production for a small site and I think it is totally fine, but what I did not fully appreciate is that SQLite is still a database, databases are complicated, and I do not know a lot about operating databases.

So here are a couple of small things I’ve been learning about running SQLite. This is the 4th website I’ve used SQLite for, and I think this one is harder because with the power of the Django ORM I’ve been making the database do more work than I was previously without Django.

I started by turning on WAL mode like all the blog posts said to do and hoping for the best.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Julia Evans

Replacing the old battery on rechargeable bike lights

AI 摘要The author repaired their decade-old rechargeable bike lights, which only held a charge for about 5 minutes, by replacing the lithium coin cell batteries (identified as LIR2477 with the help of an LLM). Following a desoldering guide and friends' advice, they removed the old batteries at a local queer makerspace, ordered replacements and silicone glue from AliExpress, soldered in the new batteries, and glued the lights back together. The repair succeeded—the lights now work for nighttime biking—and cost about $20 CAD total, which the author found rewarding despite having minimal electronics experience.

Some more things about Django I've been enjoying

AI 摘要The author describes learning to build backend-rendered websites with Django in a '2010 style' after years of frontend-heavy approaches, and highlights features they enjoy like query builders, template filters (especially `querystring`), and automatic database migrations. They dislike organizing views with inheritance, preferring function-based code instead, and are still figuring out how to reason about Django performance—notably discovering they had accidentally disabled the cached template loader, whose re-enablement significantly improved the site's request throughput.

Moving away from Tailwind, and learning to structure my CSS

AI 摘要The author describes migrating several of their small sites from Tailwind CSS to semantic HTML with vanilla CSS, explaining how Tailwind had taught them useful systems (resets, color palettes, font scales, utility classes) that they adapted while restructuring their CSS around components, base styles, spacing conventions, flexible grid layouts, and esbuild. They cite reasons for leaving Tailwind, including its growing reliance on build systems, their own improved CSS skills, Tailwind's limitations for unusual designs, and the pain of maintaining mixed codebases. Finally, they reflect on learning to respect CSS as a genuinely hard and powerful technology rather than devaluing it, and mention modern features like @layer, @scope, container queries, and subgrid that they hope to explore.

Links to CSS colour palettes

AI 摘要After deciding to stop using Tailwind CSS for new projects, the author missed its convenient color palette and asked on Mastodon for alternatives. This post compiles links to their favorite palettes (such as uchū, flexoki, and reasonable colours) as well as other palettes, color palette generators, and color tools like colorhexa and oklch resources.

Testing Vue components in the browser

AI 摘要The author describes their approach to end-to-end testing of Vue components entirely in the browser without Node.js, using QUnit along with a custom mountComponent helper, SQL-based fixture data reset via a dev server endpoint, and a polling waitFor function to handle asynchronous rendering. They share practical challenges encountered along the way, such as identifying the right DOM conditions to wait for, dispatching the proper events when filling out forms, adding CSS classes for test targeting, and using Chrome's built-in code coverage tool. The experiment was enjoyable and left the author considering Testing Library and how to eventually integrate browser-based tests into CI.