Michelle's Defragging Script Question

  • I am new to defragging/reindexing. I discovered a script by Michelle Ufford here: http://sqlfool.com/2011/06/index-defrag-script-v4-1/ It looks good. The script itself has instructions on how to call the defrag procedure once its installed, but I'm confused what I would do first. Do I just run the script she wrote as is on my maintenance database?

  • Running the initial script creates three tables dba_indexDefragLog, dba_indexDefragStatus and dba_indexDefragExclusion, creates a stored procedure [dba_indexDefrag_sp] and adds a function that the stored proc uses.

    Once these are in place, simply calling the stored proc would begin defragging every index on every database based on the default settings (which you probably don't want). We've just changed the default @database param to the db we run the script against and added the stored proc to a scheduled task.

    Read the comments at the top of the stored proc [dba_indexDefrag_sp] and familiarise yourself with what each parameter does (it is well explained). You'll most likely have no need to change any of them (apart from the @database as mentioned earlier).

    It is an excellent script and Michelle deserves all the credit she gets. The one thing that this script doesn't do, that others do, is update the statistics - which is easy enough task to set up separately.

    Hope this helps,

    Paul

    Senior Developer/Reluctant Hybrid DBA

    Edit - Just spotted it was an old post - DOH!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply