这个sql语句怎么优化啊,请教大神

select * from (select Minutely_DTU.TerminalId,[BatteryVol],Minutely_DTU.MsgArriveTime,GsmSignalStrength,
ROW_NUMBER() over(partition by Minutely_DTU.TerminalId order by Minutely_DTU.MsgArriveTime desc ) as new_index from Minutely_DTU
inner join DTUServiceInformation on Minutely_DTU.TerminalId=DTUServiceInformation.TerminalId and CancelTime is null

where Minutely_DTU.TerminalId in (select id from Terminal where Id>'6200502884' and model like 'DTU%')) a where a.new_index<='100' order by a.TerminalId

写成存储过程吧 233 下调用就只要一行了

你这样摆出来,显着太复杂了。。有些优化其实是得看一些实际情况而不是只在语句这个层面上