(1) In-depth understanding of Mysql underlying data structure and algorithm

what is index

Indexes are ordered data structures that help MySQL obtain data efficiently.

What are the data structures?

Data structure simulation website: Data Structure Visualization

  • Binary tree

It is not suitable for data structures with self-increasing IDs. As shown in the diagram below, assuming that a binary tree is used as the data storage result of the table's self-increasing primary key ID, the result is as follows: When querying the data with an ID of 5, the number of queries is 5 times.

  • red black tree

It is not suitable for MySQL indexing because when the table data is too large, the height of the tree also increases, resulting in uncontrollable height and slow query speed.

  • Hash table
  1. Performing a hash calculation on the index key can locate the location of the data storage.
  2. In many cases, Hash indexes are more efficient than B+ tree indexes.

おすすめ

転載: blog.csdn.net/h363659487/article/details/135118147
おすすめ