mysql interview question 4: What are clustered indexes and non-clustered indexes in MySQL? What are MySQL primary key indexes, unique indexes, and full-text indexes?

Insert image description here

This article focuses on interviews. In interviews, you only need to answer the key points. You do not need to have a very in-depth answer to the framework. If you want to cope with the interview, it is enough. Grasp the key points.

Interviewer: What is a clustered index and what is a non-clustered index in MySQL?

In MySQL, clustered indexes and non-clustered indexes are two different index types.

  1. Clustered Index:
    Clustered index is a sorting method on physical storage, which determines the physical storage order of data on disk. A table can only have one clustered index, usually the primary key index. When a clustered index is created, the data rows are physically stored on disk in index order. The advantage of a clustered index is that it can speed up data reading because related data rows are stored physically adjacent to each other, reducing the number of disk I/Os.

  2. Non-clustered Index:
    A non-clustered index is an additional index created in addition to the clustered index. A table can have multiple non-clustered indexes to speed up data searches based on index columns. The non-clustered index stores the values ​​of the index columns and pointers to the corresponding data rows, through which the actual data rows can be found. The advantage of non-clustered index is that it can speed up data retrieval, but after finding the specific data row, you still need to find the actual data based on the clustered index.

Key point:
Clustered index determines the physical storage order of data on disk. A table can only have one clustered index, usually the primary key index. A nonclustered index is an additional index created outside of a clustered index. A table can have multiple nonclustered indexes. Clustered indexes can speed up data reading, while non-clustered indexes can speed up data retrieval. <

Guess you like

Origin blog.csdn.net/qq_27471405/article/details/133367290