概念:
能干嘛:
使用:explain+sql 语句
字段解释:
1. id (可以查看表的读取顺序)
2. select_type (数据读取操作的操作类型)
两个表union操作就会出现union result操作。
3. table 显示这一行的数据是关于那张表的
4.type(重要)
4.1 system,const
4.2 eq_ref 刚好只有一条记录匹配
4.3 ref 匹配单个值的所有行
4.4 range
4.5 index
4.6 all
5. possible_keys(可能引用的索引)和key(实际使用的索引)
查询中若使用覆盖索引,则该索引仅出现在key列表中
6. key_len
7. ref (显示哪些索引被实际使用)
8. rows (每张表有多少行被优化器查询)
建完索引后,前后对比。
9. Extra
9.1 Using filesort(重要)
糟糕的
9.2 Using temporary(重要)
糟糕的,比using filesort更坏
9.3 using index(重要)
好的
覆盖索引
9.4 using where(表示使用了where过滤)
9.5 using join buffer(表示使用了连接缓存)
9.6 impossible where
9.7 select tables optimized away(了解)
9.8 distinct(了解)
结束收手工,热身题目: