July 21, 2009 at 1:34 pm
I have a stored procedure that normally will run in less than a second. I have noticed recently that it is taking longer and longer to run. the only way i have found to fix it is to reindex the underlying tables almost on a daily basis. While the statistics don't show that the indexes are defragmented it still seems to fix the problem. Is there something else that would make it look like this fixes the problem but that's not really it? Any insight would help.
July 21, 2009 at 2:38 pm
it's statistics that is killing your query.
as statistics get more and more out of date, the saved execution plan takes longer and longer, as the original plan is inaccurate.
reindexing also rebuilds your statistics; and if you have auto update statistics turned on, that does not occur until 20% of the rows in the table has changed...on a big table, that might be a long time.
add a job to update your statistics.
Gail has some great detailed info on her blog about statistics if you want a more detailed explanation:http://sqlinthewild.co.za/
Lowell
July 21, 2009 at 5:25 pm
Perhaps it's also time to do a couple of other things...
1. Re-evaluate what the clustered index is.
2. Optimize the code to be a bit more bullet proof.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply