系统与基础设施coding-geek.com编辑精选
关系型数据库是如何工作的?
How does a relational database work?
2015 — 2019,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
一篇图文并茂的长文,系统讲解关系型数据库的内部原理:从 B 树索引、哈希结构等基础数据结构,到查询优化器如何选择执行计划,再到事务与缓冲区管理。作者以通俗易懂的方式拆解了数据库引擎的核心机制。
为什么经久不衰:数据库是几乎所有系统的地基,这篇文章把晦涩的内部机制讲得清晰透彻,多年后仍是理解 SQL 背后发生了什么的最佳入门读物之一。
HN 评论精选
文章只是入门,数据库引擎是算法与数据结构密度最高的软件系统之一
对传统 OLTP 架构很好的概述。虽然文章看起来已经很复杂,但这只是冰山一角,许多更高级设计中常见的内部机制甚至没有提及,而文章已经够长了。我最喜欢数据库引擎的一点是:同等规模的软件系统里,它每行代码包含的硬核计算机科学可能是最多的,对算法和数据结构爱好者来说是非常丰富的生态。
jandrewrogers查看英文原文
Good overview of traditional OLTP architectures. As complicated as they look from the article, it is just scratching the surface of a sophisticated implementation. There are many internals common to more advanced designs that are not even mentioned, and the article is already quite long! The thing I love most about database engines is that there is probably more hardcore computer science per line of code than any other software system of similar scope. It is a very rich ecosystem for an algorithms and data structures geek.
理论复杂度不等于实际性能,哈希表的最坏情况是数据库多用树结构的原因
注意理论上的渐进复杂度(大 O)与实际执行时间的关系。例如算法是 O(1),但内部调用了 O(log n) 的 malloc,整体就是 O(log n);更糟的是平均常数时间的算法实际可能是 O(n),比如哈希表重建索引——这也是为什么许多大数据结构(包括多数 SQL 数据库)用树而非大哈希表来实现。
faragon查看英文原文
Be careful with theoretical asymptotic complexity (big O) related to execution time. E.g. if your algorithm time complexity is O(1), but internally calls a higher complexity function, e.g. malloc(), implemented with higher complexity, e.g. O(log n), your algorithm time complexity would be O(log n) and not O(1). It could be even worse: on average or typical constant time algorithm could be in reality an O(n) one: e.g. case of hash table reindexation (that's the reason of why many big data structures, including most SQL databases, requiring real time behavior, are implemented as trees, tree hierarchies/division/clustering, instead of big hash tables).
推荐配套阅读伯克利的《Architecture of a Database System》
写得好。另一个我一直放在手边的优秀资源是 UC Berkeley 数据库组三位研究者写的《Architecture of a Database System》,非常易读。
why-el查看英文原文
Good write up. Another excellent resource straight out of the UC Berkeley Database Group that I keep close by is "Architecture of a Database System"[1] by three researchers in the field. It is very readable. [1] http://db.cs.berkeley.edu/papers/fntdb07-architecture.pdf
每个靠 SQL 吃饭的工程师都应了解数据库底层原理
认真说,关系数据库的基本原理和查询的物理执行方式,至少应该在每个以写 SQL 为生的工程师的脑海深处。好文章!
jeffdo查看英文原文
...thanks for reminding me of my advanced relational db exam I just had today! But in all seriousness, the fundamentals of how relational DB's work and physically execute queries should be at least in the back of the mind of any engineer who writes SQL for a living. Great article!
历次讨论
同类还值得读
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编辑精选