(4)type:重点
从最好到最差依次是: system>const>eq_ref>ref>range>index>all
  eq_ref:双表:前一个表的唯一索引只能在后表中找到唯一记录
(5)key、possible_keys(可以用来做索引失效的校验)
查询的字段就在索引中(顺序和个数都匹配),此时展示的情况就是possible_keys为空但key中有值 (6)key_len:  key_len只计算where条件用到的索引长度,单列索引计算整个索引长度,多列索引用多少算多少 (7)ref
格式:库.表.字段 const  (8)rows
 (9)extra 额外内容   Using filesort说明:最左原则,中间如果断了就不走索引了
前3个是extra中最重要的指标 
三、索引优化
单表分析
范围之后的索引会失效  结论:跳过范围比较的字段来创建索引

两表分析
问题:加在左表还是右表,主键还是外键 分析: 第一种情况:左连接把索引加在了右表上  第二种情况:左连接把索引加在了左表上

结论:左右连接索引相反加(加在从表上效率高)
(对应:可以尝试更换sql语句中的主从表位置)
三表分析

 结论:索引最好设置在需要经常查询的字段上

|