当前位置: 代码迷 >> Sql Server >> 一个SQL的效率 求解答,该如何处理
  详细解决方案

一个SQL的效率 求解答,该如何处理

热度:39   发布时间:2016-04-24 21:29:36.0
一个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就深恶痛绝,极坏的编码习惯
  相关解决方案