The most left-prefix index of the Joint Statement of Principles Mysql

We all know that the most left-prefix principles Mysql database.

For example the following table, the table has three fields a, b, c

table

a b c
     

 

 

 

Now I have built a unique joint index: `uk_a_b_c` (a, b, c)

Well, according to the most left-prefix match principle: I am in the query, the following cases can be used in the index:

 

1select * from table where a = 12select * from table where a = 1 and  b =13select * from table where a = 1 and  b =1 and c= 1

(4select * from table where a = 1 and c= 1

 

The first three are well understood, the fourth bit around

The principle is:

B + tree data item is a composite data structure, such as (name, age, sex) when, b + number is from left to right in order to build a search tree.

For example, when (Zhang, 20, F) so that the time to retrieve the data, b + tree name priority comparison determines the next search direction, if the same name and age Sex comparison in turn, finally resulting data retrieval;

But when the data (20, F) there is no such a name came, b + tree node does not know what the next step to the investigation, because the time to establish the search tree name is the first comparative factor must first be searched based on name do you know where to go next query.

For example, when (Zhang, F) ​​to retrieve such data, b + tree name can be used to specify the search direction, but the lack of age next field, so only the name is equal to the seating of the data is found, then the matching sex F of the data, this is a very important property, namely the left-most matching characteristics of the index.

Guess you like

Origin www.cnblogs.com/yuerugou54/p/11323484.html