Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use lvh
Database changed
mysql> explain select * from job_queue where 1=1 order by opt_time desc ;
+----+-------------+-----------+------+---------------+------+---------+------+--------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+------+---------------+------+---------+------+--------+----------------+
| 1 | SIMPLE | job_queue | ALL | NULL | NULL | NULL | NULL | 454244 | Using filesort |
+----+-------------+-----------+------+---------------+------+---------+------+--------+----------------+
1 row in set (0.00 sec)
mysql> explain select * from job_queue where 1=1 order by opt_time desc limit 100,10;
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
| 1 | SIMPLE | job_queue | index | NULL | ind_opt_time | 9 | NULL | 110 | |
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
1 row in set (0.00 sec)
mysql> explain select * from job_queue order by opt_time desc limit 100,10;
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
| 1 | SIMPLE | job_queue | index | NULL | ind_opt_time | 9 | NULL | 110 | |
+----+-------------+-----------+-------+---------------+--------------+---------+------+------+-------+
1 row in set (0.00 sec)
mysql>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-731553/ ,如需转载,请注明出处,否则将追究法律责任。