周梦康 发表于 2018-02-26
分类于
mysql> explain select `aid` from article_rank where `day`>20170101 group by aid limit 10;
+----+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
| 1 | SIMPLE | article_rank | index | idx_day | u_aid_day | 8 | NULL | 10 | Using where; Using index |
+----+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
1 row in set (0.00 sec)
mysql> explain select `aid`,sum(`pv`) as num from article_rank where `day`>20170101 group by aid limit 10;
+----+-------------+--------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| 1 | SIMPLE | article_rank | range | idx_day | idx_day | 4 | NULL | 243 | Using where; Using temporary; Using filesort |
+----+-------------+--------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
1 row in set (0.00 sec)
本博客是否对你有帮助呢?赞赏的人最可爱
如果觉得这篇文章不错的话,可以分享到