Does mysql use B-tree,B+tree or both?
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 of B+TREE
? This question should be posed to some MySQL or MariaDB engineer, but I see at least two possible reasons:
- B+TREE would be a very bad keyword, because it contains
+
, which is usually an operator. - That syntax is older than InnoDB. It is probably as old as the
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:
- B+Tree is faster for sorting;
- B-Tree is faster when you insert values in the middle.
But in general, B+Tree is considered superior. How much? I don't know, but surely not orders of magnitude.