In the MySQL Innodb storage engine, the index is the data, and the data is the index.
Index type
- B+ tree index: Innodb engine uses this index type internally.
- Hash index: Based on a hash table, it is used to precisely match the data pointed to by the index.
- Full-text index: only supported by MyISAM engine, mainly used to find keywords in the text, rather than directly comparing with the value in the index.
- Adaptive hash index: Innodb engine uses, automatically establishes a hash index according to the frequency of access.
Index type
- Clustered index, also called clustered index, primary key index, primary index.
- Non-clustered index, also called secondary index.
Clustered index
There must be one and only one table in a table, and the leaf nodes store all the column data of the row. A clustered index is generated when the table is built, and this clustered index is the place where data is added, deleted, modified, and checked. The clustered index is a B+ tree structure, and all leaf nodes are row data. The clustered index is created with the primary key. If the primary key is not created when the table is built, a unique index is used as the primary key. If there is no unique index, a hidden primary key column is generated at the bottom layer.
Nonclustered index
For non-clustered indexes, the leaf nodes only store the indexed column and primary key data. If the queried value is not in the index, it will return to the table: get the primary key value and go to the clustered index query. You can use a covering index to avoid returning to the table, create an index column that contains the query result, or only query the index column.
Non-clustered indexes are divided into:
- Ordinary index: The column value can be the same as the column index.
- Unique index: The column value is unique and the change buffer is not used.
- Composite index: also called joint index, composite index, index composed of multiple columns.
- Combined unique index: also called joint unique index, compound unique index, a unique index composed of multiple columns.