sql 字符串格式时间(查询条件)查询 慢!!!
本帖最后由 DistantSola 于 2013-12-09 17:44:09 编辑
select (略) from (
select row_number()over( order by c.lastdistributetime desc) as rn,c.customcode
from custom c with(nolock)
where c.status=1 and c.istodis=0 and c.ownercode='316572600816'
--and c.CreateTime>=convert(varchar(20),'2013-12-03 00:00:00')
--and c.CreateTime<=convert(varchar(20),'2013-12-09 23:59:59')
and c.CreateTime>='2013-12-03 00:00:00'
and c.CreateTime<=convert(varchar(20),'2013-12-09 23:59:59')
) ca left join custom_view cv on cv.customcode=ca.customcode where ca.rn between 1 and 10
查询需要2.6秒左右
去掉时间条件0.23秒
客户表(Custom)数据120W
注:时间已加非聚集不唯一索引
求高手解决 希望控制在1秒以内
------解决方案----------------------try
c.CreateTime>='2013-12-03 00:00:00'
and c.CreateTime<'2013-12-10'
------解决方案--------------------能把执行计划贴出来看看不。