explain select * from xuehao;
mysql> explain select * from xuehao;
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | xuehao | ALL | NULL | NULL | NULL | NULL | 8 | NULL |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
1 row in set (0.03 sec)
type
all 全表扫描,mysql遍历全表来找到匹配的行
index 索引全扫描,mysql遍历整个索引来查询匹配的行
range 索引范围扫描,常见于<,<=,>,>=,between等操作
ref 使用非唯一索引扫描或唯一索引的前缀扫描
eq_ref 使用的索引时唯一索引
const/system 表中最多有一个匹配行
NULL 不访问表或者索引,直接就能够得到结果