SQL Server database fragmentation

Source: Internet
Author: User

When the logical order of the page where the index is located is based on the primary keyword and the physical order in the data file does not match, fragments are generated. All leaf pages contain pointers to the previous and next pages. In this way, a double-stranded table is formed. Ideally, the physical order of pages in the data file will match the logical order. The performance of the entire disk is significantly improved when the physical sequence matches the logical sequence. For some specific queries, this will bring excellent performance. When the physical sorting and logical sorting do not match, the disk performance will become inefficient because the head must move forward and backward to search for the index, rather than searching in a single direction. Fragmentation affects I/O performance, but it does not affect data pages in the SQL server data buffer.

Before Sorting index fragments, make sure that system resources, such as physical disk fragments and unreasonable infrastructure, have a negative impact on performance. For more information, see kb935089: use the defrag manager to fragment the volumes of the such as exchange server or SQL Server database server.
DBCC showcontig is used to display the data and index fragmentation information of a specified table. When running this command, pay special attention to the two metrics: Logical fragmentation and page density.

page scanned-Number of scanned pages: if you know the approximate size of rows and the number of rows in the table or index, then you can estimate the number of pages in the index. Look at the number of scanned pages. If it is significantly higher than your estimated number of pages, it indicates there are internal fragments.
extents scanned-Number of scanned extended disk areas: divide the number of scanned pages by 8 and rounding them to the next maximum value. This value should be consistent with the number of scan extended disk areas returned by DBCC showcontig. If the number returned by DBCC showcontig is high, external fragments exist. The severity of fragments depends on the value displayed just now, which is higher than the estimated value.
extent switches-Number of switches in the extended Disk Area: the number should be equal to the number of scanned extended disk areas minus 1. If it is high, external fragments exist.
avg. pages per extent-average page number on each extended Disk Area: This number is the number of scanned pages divided by the number of scanned extended disk areas, generally 8. If the value is smaller than 8, external fragments exist.
scan density [best count: actual count]-scan density [optimal value : actual value]: DBCC showcontig returns the most useful percentage. This is the ratio of the Best Value of the extended disk to the actual value. The percentage should be close to 100% as much as possible. If it is low, external fragments exist.

Logical scan fragmentation-logical scan fragmentation:Unordered page percentage. The percentage should be between 0% and 10%. If the percentage is high, external fragments exist.
Extent scan fragmentation-extended Disk Area scan fragments:The percentage of unordered extended disk areas on the scanned index leaf page. The percentage should be 0%. If the percentage is high, external fragments exist.
AVG. bytes free per page-average number of available bytes per page:The average number of available bytes on the scanned page. The higher the description, the more internal fragments are. But before you use this number to determine whether there are internal fragments, consider the fill factor ).
AVG. Page density (full)-average page density (complete ):The opposite of the percentage of available bytes on each page. A low percentage indicates that internal fragments exist.

Reference: Microsoft SQL Server 2000 best practices for index fragmentation

How to minimize the number of index fragments

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.