Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

As data is modified in a database, the database and its indexes become fragmented. As indexes become fragmented, ordered data retrieval becomes less efficient and reduces database performance.

Understanding the different types of fragmentation

...

There are several types of fragmentation that can occur and impact SQL Server performance and space usage. Note that logical order and page density issues exist on tables and indexes within SQL Server. These issues cannot be resolved by operating system level defragmentation tools because the fragmentation exists within the files, rather than at the file level itself.

...

This issue, also known as internal fragmentation, occurs as pages split , causing suboptimal use of the capacity of each page. There may be excessive free space left on the pages. SQL Server may need to read more pages than necessary to satisfy a query or perform other activities.

 

File fragmentation at the operating system level occurs during the normal operation of your computer when you create, delete, and modify files. When you delete a file, newly freed disk space is left behind. Then, when you create a file or install a program, the operating system needs to use that space. The new file may be larger than the free space left from a prior deletion, so it puts part of the file into the space left by the deletion, and the rest of the file somewhere else on the disk, leaving a fragmented file.

Fragmentation within SQL Server occurs in much the same way. When data is inserted, deleted, and modified over time in a table, an index can cause the pages to be out of order. The next logical page may not be the same as the next physical page. This issue is known as logical order fragmentation.

...

make room for information added to a page, there may be excessive free space left on the pages. This extra space can cause SQL Server to read more pages than necessary to perform certain tasks.

...

 

SQL

...

Defrag Manager defragments the leaf level of an index so the physical order of the pages matches the left-to-right logical order of the leaf pages. The leaf pages of a clustered index contain the table data. This process improves index scanning performance and all data retrieval activities.

Fragmentation examples

Imagine there are two data pages for a table with a clustered index. The data is ordered and the pages are full as shown in the following figure. A new row with a primary key of "5" needs to be inserted, and since it is a clustered index, the new row is inserted in order. Because the target page is full enough that the new row does not fit, SQL Server splits the page roughly in half and inserts the new data on the new page, as shown in the following figure. Now, the logical order of the index does not match the physical order, and the index has become fragmented.

...

Depending on the policy settings you select, SQL Defrag Manager defragments tables and indexes in one of the following ways: 

Rebuild

The To rebuild the indexes on tables, the rebuild defragmentation type option uses the DBCC DBREINDEX command to rebuild the indexes on the tables. ALTER INDEX REBUILD command for SQL Server 2005 and newer versions. For SQL Server 2000 it uses DBCC DBREINDEX.  The rebuild operation creates new, contiguous pages. SQL Server 2005/2008 allows the option to Rebuild Online, which allows access to the tables before the operation is finished. However, choosing to rebuild online requires more resources (disk space, CPU, memory), and may slow performance. 

Reorganize

The reorganize defragmentation type uses the DBCC INDEXDEFRAG command to To reorder the leaf pages of the index in-place, the reorganize defragmentation option uses the  ALTER INDEX REORGANIZE command for SQL Server 2005 and newer versions. For SQL Server 2000 it uses  DBCC INDEXDEFRAG . This process is similar to a bubble sort. Although the pages are physically reordered, they may not be contiguous within the data file. This issue can cause interleaved indexes, which need to be rebuilt to store them in contiguous pages.

Info

Online index operations are available only in SQL Server DatacenterData center, Enterprise, Developer, and Evaluation editions.

...

In addition to reordering the leaf pages of the index, SQL defrag manager Defrag Manager compacts the data in the pages using the original fillfactor fill factor value specified for the table and then removes any empty pages. Consider the following conditions related to this compaction phase:

  • Compaction is completely skipped if the Inhibit Page Locks property is set for the index.
  • There are various algorithms built into the compaction phase to stop unnecessary work. For example, if the first page in the index is empty and all the other pages are full, SQL Server does not repeatedly move all the data forward one page.
  • SQL Server compacts pages back to the fillfactor fill factor value defined for the index. Make sure this value is not set too high. For more information, see the SQL Server documentation.
  • If a lock cannot be obtained on a page during the compaction phase of DBCC INDEXDEFRAG, SQL Server skips that page.

...

Interleaving occurs when an index extent, which is a group of eight index pages, is not physically contiguous because an extent for another index is intermingled with it. This condition can happen even when there is no logical fragmentation in the index. Although the pages may be physically and logically ordered, they are not necessarily contiguous. Switching between extents can impact performance as data access is inefficient. To resolve this issue, use SQL defrag manager Defrag Manager to rebuild the indexes to store them in contiguous pages and reduce the need to switch between extents.



Scroll pdf ignore
Newtabfooter
aliasIDERA
urlhttp://www.idera.com
| 

Need more help? Search the IDERA Customer Support Portal

...

Newtabfooter
aliasProducts
urlhttps://www.idera.com/productssolutions/sqlserver
Newtabfooter
aliasPurchase
urlhttps://www.idera.com/buynow/onlinestore
|
Newtabfooter
aliasSupport
urlhttps://idera.secure.force.com/
|
Newtabfooter
aliasCommunity
urlhttp://community.idera.com
|
Newtabfooter
aliasResources
urlhttp://www.idera.com/resourcecentral
|
Newtabfooter
aliasAbout Us
urlhttp://www.idera.com/about/aboutus
|
Newtabfooter
aliasLegal
urlhttps://www.idera.com/legal/termsofuse

...