日期:2014-05-16 浏览次数:20813 次
SELECT * FROM `article` WHERE article_category=11 ORDER BY article_id DESC LIMIT 5 。执行时间大约要5秒左右
create index idx_u on article (article_category,article_id); SELECT * FROM `article` WHERE article_category=11 ORDER BY article_id DESC LIMIT 5减少到0.0027秒
SELECT * FROM `article` WHERE article_category IN (2,3) ORDER BY article_id DESC LIMIT 5执行时间要11.2850秒。
select * from article where article_category=2 or article_category=3 order by article_id desc limit 5
(select * from article where article_category=2 order by article_id desc limit 5) UNION ALL (select * from article where article_category=3 order by article_id desc limit 5) ORDER BY article_id desc limit 5