SQL Server Database Index Fragmentation: Why You Should Care About It

by Aug 2, 2021

SQL Server Database Index Fragmentation is one of the leading culprits for slowing down your server’s response time. 

SQL Server indexes can incur different types of fragmentation which can cause a range of problems. Using an automated solution will help keep your indexes defragmented and improve SQL Server performance. 

What is SQL Server Database Index Fragmentation?

SQL Server index fragmentation is a term used to describe several related issues that afflict the platform’s database indexes. They all lead to inefficiencies in how the database processes queries and responds to requests.

Fragmentation occurs as a result of modifying information in a database. As indexes become fragmented, the efficiency of ordered data retrieval decreases along with database performance. Three main types of fragmentation can affect SQL Server systems.

Operating system level file fragmentation

This type of fragmentation happens when inserts and deletes result in the physical and logical page order being out of sync. System defragmentation tools address this kind of fragmentation and should be run before pursuing remedies for logical order and page density issues.

Logical order fragmentation

Also known as external fragmentation within SQL Server, this issue is similar to the OS level problem described above. Due to inserts, delete, and modifications, logical and physical pages become unordered. A dedicated SQL Server defragmentation methodology is required to reorder the database pages.

Page density fragmentation

Also referred to as internal fragmentation, this problem happens when pages are split to enable new information to be added. In some cases, this results in excessive free space being left on a page, slowing down SQL Server tasks as extra pages need to be accessed to fulfill a request. 

How Fragmentation Hurts SQL Server Performance

Fragmentation negatively impacts database performance both directly and indirectly in several ways.  

  • Logical order fragmentation slows down performance by requiring more work to be done to locate the data necessary to satisfy a query. As the level of fragmentation increases, databases that were previously performing up to expectations can mysteriously slow to a crawl. Rebuilding or reordering the fragmented indexes is required to resolve this issue.
  • Page density fragmentation often results in extra pages being processed when performing database tasks. This not only slows down database operations but can also extend the time required to perform backups. In addition, extra storage capacity on backup media will be used to essentially store empty space. 

Of course, the degree of fragmentation influences the severity of the problems and impacts on performance. A small amount of fragmentation may not result in noticeable effects. However, over time the fragmentation is likely to grow and cause substantial performance degradation.

A Tool to Maintain Efficient SQL Server Indexes

SQL Defrag Manager offers database administrators (DBAs) a tool capable of automating the task of defragmenting SQL Server indexes. It automates the identification of fragmented indexes based on customizable policies defined for the target SQL Servers. This saves the database team a lot of time, allowing them to concentrate on more productive endeavors. 

SQL Defrag Manager provides a central management console for configuring defragmentation parameters, monitoring activity, generating reports, and tracking improvements to the target SQL Servers. Defragmentation can be performed via schedules when thresholds are exceeded or manually,  on-demand when necessary.

SQL Defrag Manager defragments tables and indexes by rebuilding or reorganizing based on policy settings. Rebuilding is done using the DBCC DBREINDEX command and can be done online or offline.

Reorganizing is the second defragmentation option and is performed via the DBCC INDEXDEFRAG command. Scheduling defragmentation allows teams to regularly address fragmentation during times of off-peak usage and eliminates most of the need for manual intervention.

I’d like to recommend a short but informative IDERA video that gives viewers a hands-on demonstration of automating SQL Server index defragmentation. Implementing this practice will save DBAs valuable time and help their SQL Server databases perform optimally. 

Try SQL Defrag Manager for free!