1. The physical storage position index
1.1mysql storage directory resolve
1. Database file storage location: my.ini configuration file, datadir data corresponding directory location.
2. Each database corresponds to a folder
a.MYISAM engine: each table corresponds to the three documents
* .MYI: data is stored in the index table corresponding to the index information and content;
* .FRM: configuration information is stored in the data table;
* .MYD: the content is stored in the data table;
b.InnoDB engines: one file for each table
* .Frm configuration information is stored in the data table
* Data contents and index files are stored in a unified ibdata file.
3. The index files are extra for storage, the corresponding index queries and maintenance of all need to consume IO;
1.2 index storage structure (index principle)
1) b-tree (balanced tree): it is the most used mysql index type, in innodb, there are two types of index:
The first is the primary key index (primary key), the address data is stored directly in the content index;
The second is the general index, the content stored in the index is pointing to the primary key index of reference; so when using innodb, we should try to use the primary key index, the speed is very fast;
Save the b-tree data is data stored in a certain order, can be tolerated in a range of query;
2) hash: the index value of the hash function to make, store the hash table.
Advantages: Since the hash table is stored using, according to common sense, hash performance much higher than the efficiency B-TREE.
Disadvantages: 1, hash index only for precise comparison value, =, in; or <>; range queries can not be used;
2, can not use the index to sort
3, the combination can not use the hash index indexes portion;
4, if the hash values are the same mass index, lower performance;