Why not create an index for sex

Original link: https://blog.csdn.net/Sunmeok/article/details/82965805

If there is a query to query data for the male gender, because such data are many, many times we have to scan the index, then go get the male gender data.
Then divided into two parts, the first index scan, then pick up this data to meet the requirements.
If we do not build an index, to scan the entire table.
Not indexing time = T required to scan the entire table
setup time required index = T + T to index scan the entire table to take
us to consider an extreme, as if the whole male gender, then we index to find the time is T scanning the entire index table + T scan the entire table. So certainly took too big. So our conclusions

They come in through the elaborate innodb and MyISAM

MyISAm in: that is similar to the above description, it is necessary to go to scan the index tree, go to the scan table.
Here Insert Picture Description

Innodb in: its index and data together, it's a non-clustered index to retain the index of the current column and the primary key columns, each search but also to the primary key index to find the entire confidence, because the primary key index that contains all node information , then there will be time consuming problem when converting non-clustered index to a clustered index, as in the above case.

One might ask, if placed on a clustered index to find duplicate more than one column, that does not matter, the problem is clustered index is unique and can not be repeated

Here Insert Picture Description

About index storage structure:

https://www.cnblogs.com/zlcxbb/p/5757245.html

https://www.cnblogs.com/weizhixiang/p/5914120.html

These two articles are good, but I think it's better to write the first chapter.

Guess you like

Origin blog.csdn.net/qq_40802017/article/details/102760352