How do I do reindexing & defragmentation of my database

  • Nowadays my database is running very slow.

    So I have decided to do re indexing & defragmentation.

    I have did shrinking of database.

    Here first time I am doing re indexing & defragmentation of database.

    How do I go for this. Is there any procedure for this task.

    What are the commands/stored proc, steps take to consider.

    please reply soon __.____._

    Regard

    Majid

  • mjafar (2/5/2008)


    Nowadays my database is running very slow.

    So I have decided to do re indexing & defragmentation.

    I have did shrinking of database.

    Here first time I am doing re indexing & defragmentation of database.

    How do I go for this. Is there any procedure for this task.

    What are the commands/stored proc, steps take to consider.

    please reply soon __.____._

    Regard

    Majid

    You could rebuild or defragment your indexes using ALTER INDEX statements. Whether to rebuild, defragment or do nothing, you can decide based on the output of sys.dm_db_index_physical_stats, This is described in a lot of detail in Books Online under http://technet.microsoft.com/en-us/library/ms189858.aspx.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • You can construct an SSIS package from Management Studio to accomplish your goal; remember to schedule the associated Agent Job.

    To save time and system resources you may want to start w/ a Reorganize Index task in your package instead of Rebuild Index.

  • And don't run a shrink of the data files - it will cause fragmentation. I documented this in SS2005 Books Online for DBCC SHRINKDATABASE. See http://www.sqlskills.com/blogs/paul/2007/11/13/AutoshrinkTurnItOFF.aspx for an example.

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • Refer to OP's other post on this please- Reindexing and defragmentation (SQL 2000)

    Apparently server is 2000, post was initially in wrong forum.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

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