rwheeler23
asked on
SQL in what order should utilities be run?
I was running an index checking routine in our ERP solution and noticed very quickly that it freezes. Going into SQL Profiler indicates no activity. So I stopped the utility and went into SSMS. Running dbcc checkdb indicated zero inconsistencies. However, running a routine that checked fragmentation revealed a good portion of the tables are fragmented well beyond 15%. I have a script ready to rebuild these indexes. My question here is should I update statistics prior to rebuilding the indexes? Are there any other SQL utilities I should be running? The current database is running SQL 2008 R2 but can easily be upgraded to SQL 2019. I have a feeling no one has ever run any SQL utilities on this 20 year old database.
ASKER
Good to know. Thank you. I was doing this first in a test environment. So I do not even need to specify WITH FULLSCAN when I rebuild the indexes?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
No, you don't need nor want to update stats before rebuilding indexes. The index rebuild itself will update the stats with the equivalent of WITH FULLSCAN; therefore, you never want to update stats after an index rebuild either.