MySql index underlying principle

Objective: To get through mysql data, retrieve data to understand the principle of indexing, and how to make good use of the index.

Due to space problems that may serialized articles.

 

Speaking from a data acquisition mysql:

We know that the computer system at the time of acquiring data disk rotates, then moves the head, then the data corresponding to the disk portion removed.

But mysql data location on the disk may not necessarily be continuous, so a visit might take the cost to be much larger than we think about,

So we want to improve search speed, it must find a way to improve the retrieval speed other (index).

Index structure will normally there are many: B-tree, Hash, bitmap index like.

Description premise: a drawing memory area of ​​each circle represents the index. So visit a circle (index node) will have a IO.

So drawbacks generated: before the head reaches the target data, each through a node, it must produce a IO, so the amount of data increases, the number of nodes will gradually increase.

IO will make the increase in the number.

Red-black tree has changed in terms of look, each additional node at the same time, will go through a balancing algorithm, the node will try to spread out,

As much as possible to reduce the red-black tree unilateral too long. But with the increase of the same amount of data will increase the number of IO.

 

To solve this problem: mysql introduced than the first two (there is no absolute priority) B + tree.

In order to reduce the number of IO, mysql Index to a memory area is enlarged to accommodate the size of the n-th root (orange region).

That is, we know B + Tree.

 

Guess you like

Origin www.cnblogs.com/zwk-It-goodmorning/p/11258291.html