周梦康 发表于 2015-08-26 2574 次浏览 标签 : Mysql
mysql> explain select uid from recommend_user order by `rank` desc;
Connection id:    865094
Current database: hujia

+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table          | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+
|  1 | SIMPLE      | recommend_user | ALL  | NULL          | NULL | NULL    | NULL |  136 | Using filesort |
+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)

mysql> explain select uid from recommend_user force index (idx_rank) order by rank desc limit 0,30;
Connection id:    865254
Current database: hujia

+----+-------------+----------------+-------+---------------+----------+---------+------+------+-------+
| id | select_type | table          | type  | possible_keys | key      | key_len | ref  | rows | Extra |
+----+-------------+----------------+-------+---------------+----------+---------+------+------+-------+
|  1 | SIMPLE      | recommend_user | index | NULL          | idx_rank | 2       | NULL |   30 |       |
+----+-------------+----------------+-------+---------------+----------+---------+------+------+-------+
1 row in set (0.01 sec)

评论列表