系统与基础设施sqlite.org
SQLite 的适用场景
Appropriate Uses for SQLite
2011 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
SQLite 官方文档中说明其适用场景的页面,核心观点是“SQLite 不与客户端/服务器数据库竞争,而是与 fopen() 竞争”。它详细列出了适合使用 SQLite 的场景(嵌入式设备、应用文件格式、网站数据库、数据分析、缓存等)以及应改用客户端/服务器数据库的情况。
为什么经久不衰:它以坦诚清晰的官方视角划定了嵌入式数据库与服务器数据库的边界,多年来被反复引用,是理解 SQLite 定位的必读文献。
HN 评论精选
SQLite 极适合教学:零安装成本、单文件分发,足以讲清数据库核心概念
我教非技术背景的学生 SQL。以前让他们在 MySQL 和 SQLite 之间选,但两者语法差异不小,而且让学生成功安装运行 MySQL 服务器和客户端绝非易事。后来我把所有课程都迁移到 SQLite,非常满意:作业分发更容易(一个 SQLite 文件,而不是需要手动导入的 CSV),而且足以讲清关系型数据库和连接操作的概念。通常只需只读访问,所以作业涉及几个 GB 的数据也没问题。
danso查看英文原文
I teach SQL to non-techie students. I used to give the the option of doing either MySQL or SQLite, but not only did I underestimate how different the syntaxes were, I also underestimated how not-trivial it is for students to successfully install and run both the MySQL server and client. These are students who can't even use a spreadsheet well, not that that makes a huge difference in understanding databases. I've moved everything to SQLite and couldn't be happier. Not only is it easier to distribute assignments (e.g. a single SQLite file, instead of CSVs that need to be manually imported), it does everything I need it to do to teach the concepts of relational databases and join operations. This typically just needs read-only access, so our assignments can involve gigabytes of data without issue.
SQLite 的定位是替代直接读写文件,而非替代大型数据库服务器
我一直很喜欢这句话:“SQLite 不与客户端/服务器数据库竞争,SQLite 与 fopen() 竞争。”我用 TCL 写过一些使用 SQLite 的小应用,体验很好,用起来和直接操作文件差不多省事。
AstroJetson查看英文原文
I've always loved this line: SQLite does not compete with client/server databases. SQLite competes with fopen(). I have some small apps that I've written in TCL that use SQLite that I've been very happy with. Not much more effort than using a file. There are also some nice hooks to allow the use of SQLite from Lua scrips. It's pretty easy and it fits into the Lua world view of data.
对个人和小项目来说,SQLite 省去运维负担,是极佳选择
我副业的网站后端就跑在 SQLite 上,这是我做过的最好的技术决策之一。性能不错,极其简单直接(白天工作里有专门的 Postgres 团队维护数据库,但副业没有这种资源),备份也简单得要命。
xiaomai查看英文原文
I run the backend/website of my side business on sqlite. It is one of the best technology decisions I have made. It performs reasonably, is super straightforward (at my day job we have a team of postgres people to keep our dbs running smoothly, but for my little side business I don't have those resources); backups are dead simple. I love sqlite.
SQLite 的性能取决于使用方式:单进程长连接时性能不输传统数据库
理解 SQLite 性能差异的关键在于:普通数据库系统有一个专门进程接收处理 SQL 查询并独占数据库文件,而 SQLite 没有这种进程,每个客户端都要自己打开文件、处理 SQL、再关闭写回。所以如果多个进程访问同一个 SQLite 文件,会因文件系统的反复读写而变慢;但只要只有一个进程使用并保持连接,性能可以与其他数据库相当,用得当时 SQLite 可以非常快。
JepZ查看英文原文
Well, actually it is very simple when you understand the why SQLite performs differently than other database systems. The major difference is that 'normal' database systems have a process which receives and processes SQL queries and has the exclusive access to the database file. SQlite on the other hand doesn't have such a process so, every client has to open the database file itself, process the SQL and close/write the file again. So the biggest difference is, that if you want to use SQLite, you will have to limit your database operation to one or fewer ;-) processes to not get into a situation where one process has to wait until the other finished writing the database file to the filesystem just to read it again in the next moment. Otherwise your filesystem and the continuing reading and writing of the database file will make the whole thing very slow. But as long as you have only one process using the SQLite file and keep it open for a while you will see a comparable performance to other database systems. Actually, SQLite can be very fast if you do use it in a sane way.
历次讨论
同类还值得读
TTY 揭秘(2008)
The TTY demystified (2008)
经典文章深入剖析了 Unix/Linux 中 TTY 子系统的工作原理,包括线路规程、终端驱动、信号与控制字符等机制。
系统与基础设施上首页 11 次 · 2009–2025linusakesson.net编辑精选为什么 GNU grep 这么快
Why GNU grep is Fast
FreeBSD 邮件列表上一篇广为流传的帖子,解释 GNU grep 为什么快:核心在于 Boyer-Moore 字符串搜索算法配合精心优化的内部循环和 I/O,让程序在搜索时“…
系统与基础设施上首页 9 次 · 2010–2022lists.freebsd.orgXplain:为普通人讲解 X11
Xplain – Explaining X11 for the rest of us
《Xplain》是作者(HN 用户 Jasper_)写的一系列 X11 长文,用他在浏览器中重建的 X11 绘图模型做交互演示,讲解 X11 的绘图模型与窗口系统设计。
系统与基础设施上首页 6 次 · 2013–2020magcius.github.io编辑精选旋风教程:为 Linux 创建极小 ELF 可执行文件(1999)
A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux (1999)
breadbox 写于 1999 年的经典教程,主题是如何为 Linux 手工构造并裁剪出体积极小的 ELF 可执行文件。
系统与基础设施上首页 6 次 · 2007–2025muppetlabs.comPostgreSQL 内部原理
The internals of PostgreSQL
《The Internals of PostgreSQL》是一本免费在线书籍,系统讲解 PostgreSQL 的内部实现,包括查询处理、并发控制、WAL、缓冲区管理等核心机制。
系统与基础设施上首页 5 次 · 2017–2025interdb.jp编辑精选