select *from RESOURCES where RES_STATUS = 1 and PLATFORM_FLAG=1 and RES_ID in
(select RES_ID from DOWNLOADRECORDS where DOWNLOADRECORDS_TIME > DATE_SUB(now(),INTERVAL 7 DAY)
group by RES_ID order by COUNT(*) desc ) limit 1, 10;
这条语句查处结果需要20250毫秒
select bb.* from (select * from DOWNLOADRECORDS where DOWNLOADRECORDS_TIME > DATE_SUB(now(),INTERVAL 7 DAY) group by RES_ID order by COUNT(*) desc limit 1,10) as aa,RESOURCES as bb where aa.RES_ID=bb.RES_ID and bb.RES_STATUS = 1 and bb.PLATFORM_FLAG=1;
这条语句只需要15毫秒
相同的环境下,查出相同的结果速度相差1000倍