mysql> EXPLAIN SELECT * FROM student WHERE name LIKE '%四' \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: student
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 6
Extra: Using where
1 row in set (0.00 sec)
mysql> EXPLAIN SELECT * FROM student WHERE name LIKE '李%' \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: student
type: range
possible_keys: index_name
key: index_name
key_len: 22
ref: NULL
rows: 1
Extra: Using where
1 row in set (0.00 sec)
第一个查询语句执行后,rows参数的值为6,表示这次查询过程中查询了6条记录;第二个查询语句执行后,rows参数的值为1,表示这次查询过程只查询一条记录。同样是使用name字段进行查询,第一个查询语句没有使用索引,而第二个查询语句使用了索引index_name。因为第一个查询语句的LIKE关键字后的字符串以"%"开头。