1. It is recommended to control the number of indexes in a single table within 5.
2. It is not recommended that the number of combined index fields exceed 5.
3. Join prohibits more than three tables.
The data types of fields that need to be joined must be absolutely consistent.
4. Left blur or full blur is strictly prohibited. If necessary, use a search engine to resolve it.
5. If there is an orderby scenario, please pay attention to the orderliness of the index.
Example
1)consts 单表中最多只有一个匹配行(主键或者唯一索引),在优化阶段即可读取到数据。 2)ref 指的是使用普通的索引(normal index)。 3)range 对索引进行范围检索。 反例:explain 表的结果,type=index,索引物理文件全扫描,速度非常慢,这个 index 级别比较 range 还低,与全表扫描是小巫见大巫。
The above is the detailed content of What is the specification of mysql index?. For more information, please follow other related articles on the PHP Chinese website!