MyISAM index implementation
The MyISAM engine uses B + Tree as the index structure. The data domain of the leaf node stores the data record address. Is the principle of MyISAM index:
Figure 8
There are three columns in the table. If we use Col1 as the Primary key, Figure 8 shows the Primary index (Primary key) of the MyISAM table. It can be seen that the index file of MyISAM only stores the address of the data record.In MyISAM, the primary index and Secondary index (Secondary key) have no difference in structure, but the primary index requires that the key is unique, and the Secondary index key can be repeated.If we create a secondary index on Col2, the index structure is shown in:
Figure 9
It is also a B + Tree that stores data records in the data field. Therefore,The index search algorithm in MyISAM first searches for indexes based on the B + Tree search algorithm. If the specified Key exists, the value of its data domain is taken out, and the address is the value of the data domain, read the corresponding data records.
The index method of MyISAM is also called "non-clustered". The reason for this is to distinguish it from the clustered index of InnoDB.