Files
Knowledge/1 使用/let's craft a database system.md

8 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- 为什么数据库一般使用 [dsl](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=dsl&zhida_source=entity) 语言作为数据查询接口,而不是 api 函数?
- 一条查询语句被提交给数据库之后,背后发生了多少不为人知的交易?
比如查询语句的解析成 [ast](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=ast&zhida_source=entity),解析 ast 到[逻辑 plan](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=%E9%80%BB%E8%BE%91+plan&zhida_source=entity),调整优化逻辑 plan 形成[物理 plan](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=%E7%89%A9%E7%90%86+plan&zhida_source=entity),[执行器](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=%E6%89%A7%E8%A1%8C%E5%99%A8&zhida_source=entity)高效编排plan node并执行,[存储引擎接口](https://zhida.zhihu.com/search?content_id=724181197&content_type=Answer&match_order=1&q=%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E6%8E%A5%E5%8F%A3&zhida_source=entity)操作,数据如何一步一步返回?每个步骤单独去讲,都是一个伟大的领域。
你就说里面最简单的执行器的执行和返回,火山模型还是漏斗模型亦或者是暴力 mr?解析查询语句是用工具生成还是手动优化?手动优化为了避免内存碎片和频繁回溯判断,上不上记忆链?或者 AI 推导式解析?亦或者是编译走参数化查询?这还只是里面最简单的内容,真到了物化视图延迟加载和 cbo 优化,估计头发都没了。
当你搞懂了这些点之后,大概就理解,为什么从0到 1 写个数据库的教程如此匮乏,大名鼎鼎的 let's craft a database system 却只是在实现一个 btree ?