MySQL使用的是BTree还是B+Tree

MySQL B树 B+树 大约 1192 字

查看索引

查看表account的索引。

show index from account;

输出:

mysql> show index from account;
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| account |          0 | PRIMARY  |            1 | id          | A         |           3 |     NULL | NULL   |      | BTREE      |         |               |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)

为什么是 BTREE

Index_type上显示的虽然是BTREE,但MySQL底层确实是用的B+Tree,外国友人猜测的可能原因:

  1. B+TREE不是一个很好的关键词,+号是一个操作符。
  2. 语法比InnoDB还早,可能比ISAM还早。

注意

B+Tree也是一种BTree啊!

参考

https://dba.stackexchange.com/questions/204561/does-mysql-use-b-tree-btree-or-both/204573

https://blog.jcole.us/2013/01/10/btree-index-structures-in-innodb

阅读 191 · 发布于 2021-03-10

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批