Check index density and fragmentation information for SQL Server 2005 (RPM)

Source: Internet
Author: User

Query the index density and fragmentation information for all tables in the database to provide a basis for rebuilding and collating the index, or refer to DBCC SHOWCONTIG, which is usually recommended for rebuilding over 30% fragmentatioin, otherwise it is recommended to defragment

SELECTI.name asIndexName,
O.name asTableName
S.name asSchemaName
F.index_type_desc asIndextype,
F.avg_page_space_used_in_percent asIndexdensity,
F.avg_fragmentation_in_percent asIndexfragmentation,
F.page_count asPages
fromSys.dm_db_index_physical_stats (db_id (),NULL,NULL,NULL, ‘SAMPLED') F
INNER JOINSys.objects o ono.object_id = f.object_id
INNER JOINSys.schemas s ono.schema_id = s.schema_id
INNER JOINSys.indexes I onf.object_id = i.object_id and f.index_id = i.index_id
WHEREPage_count > 50
andf.index_id > 0
ORDER byO.name, i.index_id

LIMITED | SAMPLED | Detailed | NULL | DEFAULT
These patterns affect how fragmented data is collected. Limited mode scans all pages of the heap, but for indexes, only the parent level page above the leaf level is scanned. Sampled collects 1% sample rate data in a heap or index. Detailed mode scans all pages (heap or index). Detailed is the slowest, but also the most accurate, option to perform. The effect of specifying NULL or default is the same as the limited mode.

Check index density and fragmentation information for SQL Server 2005 (RPM)

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.