Why use a covering index operation can be avoided back to the table?

Ensure tell you understand, do not understand you cut me.

First, understand two concepts - say something about the specific online are:
coverage index - select b,c,d from t1;
select b,c,d from t1 where b=1 and c =1 and d=1;
select a,b,c,d from t1 where b=1 and c =1 and d=1;
[a primary key, to establish a joint index bcd], as several sql, select out of the content, and where field conditions, the establishment of just and consistent index.
back to the table - when using non-clustered index to find data, the need to go to the primary key values clustered index and then look again complete user records, a process called back to the table.

After the above two concepts are clear, continue to look down.
Create a test table t1. Follows.
Note: a column as the primary key column, bcd establish joint index column, no other columns being indexed.

a b c d e
1 15 16 17 x
2 25 26 27 x
3 35 36 37 x
4 45 46 47 x
5 55 56 57 x
6 65 66 67 x
7 75 76 77 x
8 85 86 87 x

Execute sql, as follows:
select b,c,d from t1 where b=15 and c=16 and d=17
As used herein, the covering index. We look at his B + tree.
Here Insert Picture Description
On the map analysis, to meet the criteria, it is not complete on display at the leaf nodes? ? ? [Note: not all the contents of the table we select query is bcd three fields, in the leaf node, these three fields are not already have a corresponding value. ]
Even if we write sql like this:
select a,b,c,d from t1 where b=15 and c=16 and d=17
A is the primary key column, but on the leaf node joint of the index, primary key value corresponding to the page is stored, so back to the table still does not need to operate.

Summary: Use a covering index, we need to select out of the column, it has existed on the index leaf nodes of the tree. So back to the table does not need to operate, if we select out of a column, the leaf node is not in the joint index (such as e column of the above table), then the corresponding index value based on need, go back to the table clustered index tree correspond query the e-column values.

Guess you like

Origin www.linuxidc.com/Linux/2019-10/161058.htm