Mysql Index and its common index

Foreword

mysql index which is an index What, if just to find a few people will speak out, however,
what is the principle and purpose of the index is to establish what index needs to pay attention to?
It was designed by the difficulties encountered To create these indexes ?
The index on disk is how is how io operation, how pre-reading ?
The underlying data structure of the index is valid?
...

I think a lot of people estimated that in the face of aggressive interviewer is not cold sweat! !
In order to easing the bit interviewer, let us work together step by step to go slowly understand it ~ ~

What index is why we need an index

It is actually a key index, the database engine is a data type is an important finding data, image point that is equivalent to the sequencer inside our dictionary table, imagine if no sequencer table, we find inside a dictionary the data is not particularly difficult to find a particular need for a protracted and painstaking, and this time it played a sequencer table is particularly large role, in fact, is indexed debut. Of course, the index is not possible, improper use can lead to the opposite effect, wanted dictionary sequencer table as if blind using sound bytes, not according to certain rules and features to pour counterproductive, more harm than good.

io disk operation and pre-reading

Here Insert Picture Description
We all know the disk to read the data, the time spent in each can be divided into three parts

The average seek time average rotational delay time of data transmission

  • Average Seek Time: generally refers to the head moving time required for the specified track, the average seek time of the hard disk is generally 7.5 ~ 14ms.

  • Average rotational delay: the disk rotation data requested sectors where write head moves downward time required, we often say that the disk rotational speed, typically a disk speed of 7200r / min, 160 sectors per track each sector 512B, the disk is now about such speed and average rotational latency assigned 60 × 1000 ÷ 7200 ÷ 2 (average, need to rotate a half turn) is = 4.17ms

  • Data transfer time: time of transmission of the requested data needed to complete. Generally in a fraction of a millisecond can be ignored

Then we calculate the total cost at the time of data

The total time spent = average seek time + average rotational delay + data transmit time (negligible)
9.17ms 4.17ms = 7.5ms +

First wrote this today, tomorrow is too late in the continuing ~~

Released six original articles · won praise 7 · views 3278

Guess you like

Origin blog.csdn.net/weixin_45610260/article/details/104707448