external and internal index fragmentation rate statistics

Source: Internet
Author: User

--External debris rate >10 indicates the occurrence of external debris rate;

--Internal fragmentation rate <75 indicates internal fragmentation rate occurs

SELECT object_name (dt.object_id) Table name,

Si.name index Name,

External fragment Rate =case when

Dt.avg_fragmentation_in_percent>10 THEN ' High fragment rate '

ELSE ' normal '

End

,

Internal fragmentation rate = case when dt.avg_page_space_used_in_percent <75 THEN ' normal '

ELSE ' High fragment rate '

End

From (SELECT object_id,

INDEX_ID,

Avg_fragmentation_in_percent,

Avg_page_space_used_in_percent

From Sys.dm_db_index_physical_stats (db_id (' jinriairv2 '), NULL, NULL,

NULL, ' DETAILED ')

WHERE index_id <> 0

) as DT

INNER JOIN sys.indexes si on si.object_id = dt.object_id

and si.index_id = dt.index_id

and Dt.avg_fragmentation_in_percent >10

and Dt.avg_page_space_used_in_percent <75

ORDER BY Avg_fragmentation_in_percent DESC

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

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.