- 阿里云数字新基建系列:云数据库架构
- 朱明等
- 449字
- 2025-02-16 19:32:29
1.1 RDS for MySQL
MySQL的内核框架,在经典数据库抽象模型上基本改动不大,但由于历史原因,MySQL被迫拆分成上下两层,即服务层(Server Layer)和InnoDB存储引擎层(Storage Engine Layer)。在很多MySQL图书或资料里,对相关历史原因都有介绍,这里就不做介绍了。最终,支持事务(Transaction)的InnoDB存储引擎成为MySQL的绝对主力引擎。
RDS for MySQL主要使用的是AliSQL内核,根据云上业务和我们的实践经验,对很多MySQL行为做了优化和调整。但对总的结构没有做大的调整,基本如图1-2所示。

图1-2 MySQL的内核结构
可能有很多词,比如Mini-Transaction(MTR),读者是第一次遇到。有数据库基础的读者都知道事务的相关原理,事务的相关实现则需要底层MTR来支持。为了方便读者理解MySQL的内核结构,我们以一条SQL请求为例,展示SQL语句在MySQL内的执行全过程。首先从MySQL服务层讲起。
说明
想了解MySQL服务层,则不可避免地要找到一个合适的入口函数,因为MySQL的代码跳跃性很强,不经意间,就容易跑偏。要找到合适的入口函数,有以下几种方式。
(1)打开MySQL Profiling,会显示各主要阶段的代码文件和行数。









(2)使用调试工具,打断点,也会显示相对应的函数。

(3)使用常用的入口函数,比如dispatch_command。