explain select actor.first_name, actor.last_name, count(*) from (film_actor inner join actor on film_actor.actor_id = actor.actor_id) group by actor.actor_id\G; 与这个相比, 我的这种写法的分析结果其实更好一点,区别就在于最后group by 的actor_id是用的actor的, 结果如下, 请问为何会这样。
+----+-------------+------------+-------+---------------+---------+---------+-----------------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+-------+---------------+---------+---------+-----------------------+------+-------------+
| 1 | SIMPLE | actor | index | PRIMARY | PRIMARY | 2 | NULL | 15 | |
| 1 | SIMPLE | film_actor | ref | PRIMARY | PRIMARY | 2 | sakila.actor.actor_id | 13 | Using index |
+----+-------------+------------+-------+---------------+---------+---------+-----------------------+------+-------------+