mysql查询优化相关技巧
本文参考自 《Mysql技术内幕(第4版)》
mysql查询优化的相关操作
+----+-------------+----------+-------+---------------+------+---------+------+------+-----------------
| id | select_type | table | type
| possible_keys | key | key_len| ref
| rows | Extra
+----+-------------+----------+-------+---------------+------+---------+------+------+-----------------
| 1 |SIMPLE | car_info | range | name | name | 768 | NULL | 9 | Using where; Using index |
+----+-------------+----------+-------+---------------+------+---------+------+------+----------------
SIMPLE:未使用连接查询或者子查询的简单select语句
explain select * from car_info;
PRIMARY:最外层的select语句
explain select * from (select name from car_info where name like '凯迪拉克%') as a;
+----+-------------+------------+-------+---------------+------+---------+------+------+-------------
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+-------+---------------+------+---------+------+------+---------------
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL |