select_type: 查询类型
table: 查询针对的表
有可能是
实际的表名 如select * from t1;
表的别名 如 select * from t2 as tmp;
derived 如from型子查询时
null 直接计算得结果,不用走表
possible_key: 可能用到的索引
注意: 系统估计可能用的几个索引,但最终,只能用1个.
key : 最终用的索引.
key_len: 使用的索引的最大长度
ref: 指连接查询时, 表之间的字段引用关系.
rows: 是指估计要扫描多少行.
extra: 利用到了哪些索引,可能的值有
(1)index: 是指用到了索引覆盖,效率非常高
(2)using where 是指光靠索引定位不了,还得where判断一下
(3)using temporary 是指用上了临时表, group by 与order by 不同列时,或group by ,order by 别的表的列.
(4) using filesort : 文件排序(文件可能在磁盘,也可能在内存)
type列: 是指查询的方式, 非常重要,是分析”查数据过程”的重要依据
可能的值
(1) all: 意味着从表的第1行,往后,逐行做全表扫描.,运气不好扫描到最后一行. (2) index: 比all性能稍好一点,通俗的说: all 扫描所有的数据行,相当于data_all index 扫描所有的索引节点,相当于index_all (3) range: 意思是查询时,能根据索引做范围的扫描 如sql:explain select goods_id,goods_name,shop_price from goods where goods_id >25 \G
(4) ref 意思是指 通过索引列,可以直接引用到某些数据行 如sql:explain select goods_id,goods_name from goods where cat_id=4 \G(5) eq_ref 是指,通过索引列,直接引用某1行数据 常见于连接查询中explain select goods_id,shop_price from goods innert join ecs_categoy using(cat_id) where goods_id> 25 \G
(6) const, system, null 这3个分别指查询优化到常量级别, 甚至不需要查找时间.一般按照主键来查询时,易出现const,system 或者直接查询某个表达式,不经过表时, 出现NULL
explain select goods_id,goods_name,click_count from goods wher_id=4 \G
转载于:https://www.cnblogs.com/hgj123/p/5032444.html
相关资源:JAVA上百实例源码以及开源项目