Today work encountered, the following this section of the implementation of ultra-slow, hardly come out, run on the old server is possible, the same code, soon, on the new virtual server, super slow.
Select * from ( SelectRowNum=Row_number () Over(Order byAutoiddesc), StartTime,cast(Testtime/1000.00 as decimal(Ten,2)) astesttime,autoid fromdbo. Ftmaster M with(NOLock)WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andResult=0 andTesttype=3 and exists ( SelectAutoid from ( Select Min(bb.autoid) autoid
from (Select Max(StartTime) asStarttime,sn fromdbo. Ftmaster with(NOLock)
WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andTesttype=3 Group bySn) asAAInner Join
(SelectAutoid,sn,starttime fromDbo. Ftmaster with(NOLock)
WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andTesttype=3) asBB
onAa. SN=Bb. SN andAa. StartTime=BB. StartTimeGroup byBB. SN) TwhereT.autoid=m.autoid)) asmastertableWHERERowNumbetween(1 - 1)* 12430 + 1 and 1 * 12430
The execution of the inside is quick and why.
SelectRowNum=Row_number () Over(Order byAutoiddesc), StartTime,cast(Testtime/1000.00 as decimal(Ten,2)) astesttime,autoid fromdbo. Ftmaster M with(NOLock)WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andResult=0 andTesttype=3 and exists ( SelectAutoid from ( Select Min(bb.autoid) autoid from (Select Max(StartTime) asStarttime,sn fromDbo. Ftmaster with(NOLock)WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andTesttype=3 Group bySn) asAAInner Join(SelectAutoid,sn,starttime fromDbo. Ftmaster with(NOLock)WhereStartTime>='2014-01-01 00:00:00.000' andStartTime<'2014-12-31 23:00:00.000' andModelic='XXX' andTesttype=3) asBB onAa. SN=Bb. SN andAa. StartTime=BB. StartTimeGroup byBB. SN) TwhereT.autoid=m.autoid)
Strange SQL Server execution