September 8, 2010 at 9:02 pm
Hi,
I just shrunk the database using DBCC SHRINK statement. what would be the best approach to fix the fragmentation after shrinking the database?
September 8, 2010 at 11:17 pm
Rebuild all indexes.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 10, 2010 at 2:49 am
Rebuild all indexes via alter <<index name>> on <<table name>> rebuild
then run exec sp_updatestats
September 22, 2010 at 8:12 am
My understanding is that rebuilding all indexes will also update their statistics with full scan - so sp_updatestats will just replace the statistics with sampled ones.
Cheers,
JohnA
MCM: SQL2008
September 23, 2010 at 11:23 am
John__A is correct. Don't run the update stats sp after rebuilding all the indexes because you will be replacing stats that are based on a full scan with ones that are based on a sampled scan, possibly resulting in less accurate statistics.
September 24, 2010 at 2:47 am
do i need to rebuild all indexes one by one for each tables? as there might be a hundreds of indexes all up
September 24, 2010 at 3:13 am
I recommend to use MS script using sys.dm_db_index_physical_stats at http://msdn.microsoft.com/en-us/library/ms188917.aspx
Version 2008 R2, but versions up to 2005 are available.
September 24, 2010 at 7:52 am
Or just make a maintenance plan that rebuilds them all in all databases. Schedule it for off hours though.
August 29, 2011 at 3:01 am
Will "Rebuild all indexes" will also work with Indexes on composite primary keys?
August 29, 2011 at 4:27 pm
Yes.
August 29, 2011 at 4:39 pm
ronald_yoh (9/24/2010)
do i need to rebuild all indexes one by one for each tables? as there might be a hundreds of indexes all up
You should do as Gail suggested, Rebuild all Indexes.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
August 29, 2011 at 6:48 pm
Great! I am looking for a script that loops through the indexes so all of them can be fixed in one click.
August 29, 2011 at 7:01 pm
Scripts to rebuild the indexes.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
August 29, 2011 at 8:15 pm
Those are links of best sources that I am looking to. Thanks!
August 29, 2011 at 8:50 pm
JPJ (8/29/2011)
Those are links of best sources that I am looking to. Thanks!
😎
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply