Home > DeveloperSection > Interviews > what is index fragmentation in MS Sql Server

Posted on    November-09-2010 12:00 AM

 MSSQL Server MSSQL Server 
 2 Answer(s)
  1506  View(s)
Rate this:

Amit Singh

Total Post:565

Posted on    November-09-2010 1:00 AM

Index fragmentation is a phenomena where index contents are no longer stored continuously in the storage. When index contents become scattered in the storage, fragmented, performance on index will degrade.

If you want to see the fragmentation level of an index, you can use the system function called sys.dm_db_index_physical_stats() in the following format:

SELECT * FROM sys.dm_db_index_physical_stats(
database_id, table_id, index_id, DEFAULT, DEFAULT )

Anurag Sharma
Anurag Sharma

Total Post:19

Posted on    November-10-2010 1:00 AM

When we  perform any data modification operations (INSERT, UPDATE, or DELETE statements) table fragmentation can occur. When changes are made to the data that affect the index, index fragmentation can occur and the information in the index can get scattered in the database. Fragmented data can cause SQL Server to perform unnecessary data reads, so a queries performance against a heavy fragmented table can be very poor. If you want to determine the level of fragmentation, you can use the DBCC SHOWCONTIG statement. The DBCC SHOWCONTIG statement displays fragmentation information for the data and indexes of the specified table or view.

Don't want to miss updates? Please click the below button!

Follow MindStick