I have an application that is processing lots of items from an SQL database. It runs along fine and then after about 4 million items processed it starts hanging up.
Using SQL Server Profiler, I traced the problem to a query that jumps from a duration of around 1,000 to a duration of 2,000,000.
A simplified version of the query looks like this:
select t.field1, t.field2
from table1 t
where t.id in (select top 1000 t2.id from table2 t2 where t2.id > XXXX order by t2.id)
Any idea why it might be suddenly taking so long to execute?