October 8, 2010 at 10:58 am
Hi,
I've just set up a weekly maintenance task for rebuilding indexes on one of our servers.
I'm kind of dissapointed to see that it rebuilds ALL indexes from selected databases without taking into account if the index is fragmented or not.
Does anyone have a script for rebuilding ONLY fragmented indexes or a better strategy? Although I've set it up to execute on a low traffic hour but I wouldn't like to have our sites throwing random errors while this process is ongoing.
Rebuild indexes online has some prerequisites that we don't fulfill.
Thanks!
October 8, 2010 at 11:57 am
Does your procedure utilize the dynamic management view
sys.dm_db_index_physical_stats to check
"avg_ fragmentation_in_percent".
And then test that value to see if it exceeds say,
30 per cent to select those indexes to defrag?
Also read this forum for a further guidline(s)
http://www.sqlservercentral.com/Forums/Topic1000964-146-1.aspx#bm1001453
Pay particular attention to the post by "GilaMonster"
October 8, 2010 at 12:20 pm
If you search index rebuild on this site, there are numerous scripts to help here.
October 8, 2010 at 12:20 pm
bitbucket-25253, thanks for your answer.
My procedure is the standard one for Sql server 2005, it's not a custom procedure. I created a maintenance task "Rebuild Index"
October 8, 2010 at 12:21 pm
thanks Steve Jones. I'll take a look
October 8, 2010 at 1:16 pm
I believe the stored procedure on this link will do a good job for your requirements. Tara Kizer has been improving and enhancing this script for several years, so it is a very full featured.
Defragmenting/Rebuilding Indexes in SQL Server 2005 and 2008
October 8, 2010 at 1:28 pm
I'm a huge fan of Michelle Ufford's script, if you're looking for another option:
October 8, 2010 at 2:19 pm
Michael, Derrick: that's exactly what I was looking for. THANKS A LOT!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply