语句怎么优化啊?运行太慢了,还会出现死机 select a.buildname,b.ddate as [采集时间],b.MeterJSWD as [供温],b.MeterHSWD as [回温]
,b.MeterGY as [供压],b.MeterHY as [回压] ,b.MeterNJRL as [累计热量],b.MeterNLLL as [累计流量]
,b.Meterssll as [瞬时流量],b.Meterslrl as [瞬时热量]
,c.DoorNo,b.BuildNo,c.doorname,a.Totalhuanlu,b.bs
from TBuild as a
left join TMETERHistory2013 as b on a.BuildNo = b.BUILDNO
inner join TDoor as c on b.BuildNo = a.BUILDNO and c.DoorNo = b.DOORNO
where Meterstats = 0 and datediff(second,CONVERT(char(10),'2013-12-2 15:20:00',120) ,b.DDate) between CAST(((1 - 1 ) * 5 * 60 ) as nvarchar(100)) and CAST((1 * 5 * 60 ) as nvarchar(100)) and a.buildno=1211
分享到:更多
------解决方案-------------------- 试试建个索引:
create index idx_TMETERHistory2013_cc on TMETERHistory2013(BUILDNO,DOORNO)