Perform online index defrag

New command that allows this.

SQL Server 2000 added a new method for defragmenting your indexes, the DBCC INDEXDEFRAG command. There are some...

limitations associated with this command versus its alternative, the DBCC DBREINDEX command, namely that it doesn't completely defragment the index. However, the DBCC INDEXDEFRAG command provides a powerful alternative because it allows you to do background defragmentation while keeping your index and the table that depends on it online and in use, something referred to as online reorg.

The DBCC INDEXDEFRAG command has the following syntax:

({ database_name | database_id | 0}
         , {table_name | table_id | 'view_name' | view_id}
         , {index_name | index_id}
         ) [WITH NO_INFOMSGS]

These options are similar to the CREATE INDEX statement, and contain the means for sorting and fill factors. For a fill factor set to 0 (as above) the original fill factor for the index is used. When you use this command with a table every index of that table is defragged; or you can specify individual indexes by name or ID. To use this command you have to have to be the owner of the table or have membership in the sysadmin server role, db_owner or db_ddladmin database roles.

DBCC INDEXDEFRAG works by defragmenting the leaf levels of the indexes specified. This won't create a completely sorted index, but will provide you with the most of the performance benefits associated with defragmentation.

Barrie Sosinsky is president of consulting company Sosinsky and Associates (Medfield MA). He has written extensively on a variety of computer topics. His company specializes in custom software (database and Web related), training and technical documentation.

This was first published in April 2003

Dig Deeper on Enterprise Infrastructure Management



Find more PRO+ content and other member only offers, here.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:









  • VDI assessment guide

    Wait! Don't implement VDI technology until you know your goals and needs. A VDI assessment should consider the benefits of a VDI ...

  • Guide to calculating ROI from VDI

    Calculating ROI from VDI requires a solid VDI cost analysis. Consider ROI calculation models, storage costs and more to determine...

  • Keep the cost of VDI storage under control

    Layering, persona management tools and flash arrays help keep virtual desktop users happy and VDI storage costs down.