Innodb Index

https://www.cnblogs.com/rjzheng/p/9915754.html
Looking back four years ago, I learned of this when mysql index, the teacher talking about the index when it is like this says so

索引就像一本书的目录。而当用户通过索引查找数据时,就好比用户通过目录查询某章节的某个知识点。这样就帮助用户有效地提高了查找速度。所以,使用索引可以有效地提高数据库系统的整体性能。

Ah, so to say in fact right. But then, I read this statement, in fact, may still feel too abstract! So then, I would like to elaborate further in-depth look, so there is this article!
It should be noted that I said is only in the Mysql Innodb engine is established. In Sql Server, oracle, Mysql of Mysiam engine correctness, not be true!
OK, ado, began long-winded!
Text
index of science

First to introduce the concept of a clustered index and non-clustered indexes!
We usually use Mysql, use the following statement

CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name
[USING index_type]
ON tbl_name (index_col_name,...)

index_col_name:
col_name [(length)] [ASC | DESC]

Index creation, such as the composite index, the prefix index, the only index belong to the non-clustered index, in some books, which in turn called secondary indexes (secondary index). Later, we call it a non-clustered index, which is a B + tree data structure.

Well, the clustered index, in Mysql is no statement to another generation. In Innodb, the data is Mysql order to store the primary key. Then the index is clustered according to the primary key of each table is the row to construct a B + tree of the entire table data, stored in the leaf node. Since table data only in accordance with a B + tree sort, so a table can have a clustered index.

In Innodb, the default clustered index is the primary key index.
This time, witty readers, I should ask
to see it, one more index, will generate more than a non-clustered index tree. Therefore, many articles it said, adding the index can not be arbitrary. Because there are several indexes, there are a few non-clustered index tree! You are doing an insert operation when the need to maintain a few changes this tree! Therefore,
if the index too, insert the performance will drop!

Guess you like

Origin www.cnblogs.com/djwhome/p/12536273.html