分析sql语句格式:
explain select cat_id.count(*) from goods group by cat_id \G
返回结果:
id : 1
select_type : all
table : goods
type : range
possible_keys : cat_id
key : car_id
key_len : 2
ref : null
rows : 2
Extra : Using where
- id:sql语句的编号
- select_type:查询类型,all, SIMPLE(一个select时的取值),当有多个select时,select_type的类型分为:primary, subquery(非from子查询), derived(from型子查询),union, union result
- table:实际的表明或者表的别名,没有表名的sql设值(derived)或(null)
- possible_keys:可能用到的索引
- key:真正用到的索引
- ref:表间的引用关系
- rows:估计查询要扫描的行数
- extra:index表示使用了索引覆盖的查询结果,using_where指索引+where条件查询,using tamperary表示该查询产生了临时表,using filesort表示要文件排序。如果取出的列含有test或更大字段,filesort将会发生在磁盘上