Clustered index: Simple concept: A table based on the primary key created by a B+ tree, the index leaf node holds all the records in the table, storage records in the physical location is continuous, a leaf node holds a corresponding record (PS: is a B + tree created by the primary key , Leaf node storage data record). For example (in the case of a Chinese dictionary): The body of the Chinese dictionary itself is a clustered index, for example, we want to check the word "Ann", because the Chinese dictionary of Phonetic sorting is from "a" to "Z" end, then "Ann" word naturally ranked in the front of the dictionary, if all the "a" in the beginning of the part still cannot find the word,
"Ann" is not in the dictionary; Similarly, if you want to look up the word "Zhang", we will turn the dictionary to the last part, because Pinyin is "Zhang". In our search, we can look for the text only, that is, the body part of the dictionary itself is a directory, and we do not need to find the content we need through other directories.
The body content itself is a directory that is arranged according to certain rules and is called a "clustered index". Each table can have only one clustered index, because the catalog can only be arranged in one way, and the primary key for each table is unique.
nonclustered index: simple concept: A nonclustered index is a b + tree created from an indexed field, and the leaf node of the index holds only the index key value and the primary key that the key value points to. The stored records are logically contiguous (PS: B+ For example, we look up the word "Zhang", in the Gept table after the "Zhang" page is 672 pages, gept table "Zhang" above is "relax" word, but the page is 63 pages, "Zhang" is the word "crossbow", the page is 390 pages, it is clear that the
these words in the body is not really in the "Zhang" The next side of the word, now see the sequential "Relax, Zhang, crossbow" the three-word order is actually their sort in the nonclustered index, is the dictionary body of words in the nonclustered index mapping, we can find the desired word in this way, but this contains 2 procedures,
First find the results in the directory, Then according to find the results to turn to the page we need, this directory is purely a directory, the body is purely the text of the sort is "nonclustered index."
InnoDB B + Tree index: A.INNODB is the index organization table, that is, the data file itself is in accordance with the B+ tree storage data; The B.INNODB engine can have clustered and nonclustered indexes, each of these 2 indexes is 16k in size and cannot be changed C. Since the nonclustered index does not contain all the data for the row records, each page can hold more key values than the clustered index, and the height is generally less than the clustered index; d. If the primary key is not explicitly specified when the InnoDB table is established, InnoDB automatically creates a 6-byte column as the primary key; E.innodb, The value of the primary key is appended to the corresponding record for each non-primary key index (nonclustered index) and does not need to be added repeatedly to the Overwrite index column, which is why we often say that the smaller the InnoDB primary key length, the better; F. If the clustered index is not a federated index that contains a primary key, and does not require an additional column to hold the primary key value, it is looked up through the primary key in the Federated index. A small map showing the relationship of clustered and nonclustered indexes in InnoDB.
MyISAM B + Tree index: A.myisam is a heap organization table, without the concept of a clustered index; all row data for B.myisam table is stored in the MyD file.
MySQL's B-Tree index