I did some search on the matter and I found out that Mysql uses B+Tree index, but when I run "show index" the index type that I get is Btree. And I found in this article that Mysql uses both Btree and B+tree. If it is true that it uses both; why is it named Btree without mentioning B+tree, in which case each one is used. I know the difference between the two, and I want to do some queries to figure out the difference in performance between B-tree and B+tree indexes. Which leads to my second question, is there a big difference between the two in performing certain queries, if yes, please give an example.
Thank you in advance.
MySQL Index – Does MySQL Use B-tree, B+tree, or Both?
btreeindexMySQL
Related Question
- MySQL – Optimizing Queries Without Index Hints
- B Tree and B+Tree differences
- MySQL InnoDB – Performance for B+Tree Index with Many Duplicate Values
- What would be the maximum number of records that can be indexed with a three levels B-tree ? B+ tree
- Postgresql – Offset vs Where performance for pagination with index
Best Answer
InnoDB uses B+Tree indexes, not B-Tree. All details about InnoDB data structures can be found here. You may also want to look at these diagrams. The author of both the resources, Jeremy Cole, was head of MySQL team at Google.
Why is the syntax
BTREE
instead ofB+TREE
? This question should be posed to some MySQL or MariaDB engineer, but I see at least two possible reasons:+
, which is usually an operator.ISAM
storage engine, which exists no more. It is very possible that B-TREE was used at that time.Why does the documentation state that InnoDB uses B-Tree? Well, not all MySQL users are supposed to know what B+Tree is. This may be an oversimplification, but in that context it seems to me acceptable.
You wrote that you know the difference between B-Tree and B+Tree. Than the different performance characteristics should be clear:
But in general, B+Tree is considered superior. How much? I don't know, but surely not orders of magnitude.