I’m having a problem with an ad-hoc query that manages a fairly high amount of data. Upon executing the query, the status immediately goes into suspended state. It will stay suspended for around 25 minutes and then complete execution.
I have a mirror environment with SQL2K and the same query executes in around 2 minutes and never goes into suspended state.
@@version = Microsoft SQL Server 2005 – 9.00.3068.00 (Intel IA-64) Feb 26 2008 21:28:22 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
Perhaps the statistics are out of date and need updated. Update them but better to rebuild indexes at the same time.
Or, you don’t have any. Are stats set to create and update automatically? I’ve seen cases where they’re switched off because someone does not understand what they are for or how updates happen.
Note: the sampling rate of stats is based on the last stats update. So if you last sampled 100%, it may take some time.
What happens when you run the query twice? Is it quicker the second time?