日期:2014-05-17  浏览次数:20408 次

一个SQL的效率 求解答
select count(id) as allcount,sum(case when statusreport='-1' then 1 else 0 end) as unknow,sum(case when statusreport='0' then 1 else 0 end) as deliverd,sum(case when statusreport='2' then 1 else 0 end) as fail from msgHistory where  1=1 and SendTime>='2007-01-01' and SendTime<='2013/5/5 0:00:00'


有一千三百万数据,太慢了 怎么加快哦

------解决方案--------------------
where  1=1 and SendTime>='2007-01-01' and SendTime<='2013/5/5 0:00:00'
为什么要这样写?1=1加上后就索引就不起作用了
看到这个1=1就深恶痛绝,极坏的编码习惯