sql语句求优化,运行耗时很长。
select
max(b.doorname) as doorname,max(Meterssll) as Meterssll,max(Meterslrl) as Meterslrl
,max(MeterJSWD) as MeterJSWD,max(MeterHSWD) as MeterHSWD,max(MeterGY) as MeterGY
,max(MeterHY) as MeterHY,max(TWATERNJLL) as TWATERNJLL
,max(TElectriNJRL) as TElectriNJRL,CONVERT(char(13),a.DDate,120) + ':00:00' as ddate
from TMETERHistory2013 a
left join tdoor b on a.doorno = b.doorno
where a.BUILDNO =1211 and DDate between '2013-11-14 00:00:00' and '2013/11/28 23:59:59'
group by a.doorno,CONVERT(char(13),a.DDate,120)
order by a.DDate
------解决方案--------------------建这个索引试试:
create index idx_TMETERHistory2013_c on TMETERHistory2013(DDate,BUILDNO)
------解决方案--------------------最快捷的方法,右键绿色的字,点生成丢失索引xx的,具体名字忘记了,然后改一下索引名字就执行