Rebuilding and Reorganizing of index depends on fragmentation . By using the system function sys.dmdbindexphysicalstats, you can detect fragmentation in a specific index, all indexes on a table or indexed view, all indexes in a database, or all indexes in all databases.
The result set returned by the sys.dmdbindexphysicalstats function includes the following columns.
After the degree of fragmentation is known, use the following table to determine the best method to correct the fragmentation.
- Rebuilding an index can be executed online or offline. Reorganizing an index is always executed online. To achieve availability similar to the reorganize option, you should rebuild indexes online.