TOP 100 causing SQL Server 2008 hang? -


i have inherited poorly designed , maintained database , have been using knowledge of sql server , little luck keeping high availability server , not completing coming down in flames (the previous developer, quit kept system 4 years).

i have come across strange problem today. hope can explain me if happens again there way fix it.

anyway, there stored proc pretty simple. joins 2 tables between short date/time range (5 mins range) , passes results (this query runs every 5 mins via windows service). largest table has 100k rows, smallest table has 10k rows. stored proc simple , does:

note:the table , columns names have been changed protect innocent.

select top 100 m.* dbo.mytable1 m (nolock) inner join dbo.mytable2 s (nolock) on m.table2id = s.table2id m.rowactive = 1       , s.datestarted <= dateadd(minute, -5, getdate()) order m.datestarted 

now, if keep "top 100" in query, query hangs until stop (running in sms or in stored proc). if remove top 100, query works planned , returns 50-ish rows, should (we don't want return more 100 rows if can it).

so, did investigating, using sp_who, sp_who2, , looked @ master..sysprocesses , used dbcc inputbuffer spids might locking or blocking. no blocks , no locking.

this started today no changes these these 2 tables designs , gather last time query/tables have been touched 3 years ago , has been running without error since.

now, side note, , don't know if have this. reindexed both these tables 24 hours before because 99% fragmented (remember, said poorly designed , poorly maintained server).

can explain why sql server 2008 this?

the absolute first thing would side side comparison of query plans of full , top 100 queries , see if top 100 not performant. might need update stats or have missing indexes.


Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -