博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Sqlserver 2005+:查看索引【index】的【碎片】
阅读量:5832 次
发布时间:2019-06-18

本文共 1600 字,大约阅读时间需要 5 分钟。

set nocount onprint db_name()declare @tab_name sysnameset @tab_name='wfpuser_a0113'--内部碎片select '【内部】碎片' as frag_type    ,ob.name as object_name    ,ix.index_id,ix.name as index_name    ,ps.index_level    ,ps.partition_number    ,ps.record_count    ,ps.page_count    ,ps.fragment_count    ,str(ps.avg_fragmentation_in_percent,16,2) as [avg_frag(%)]    ,str(ps.avg_fragment_size_in_pages,16,1) as [avg_frag_pages]    ,ps.forwarded_record_count    ,ps.avg_record_size_in_bytes    ,str(ps.avg_page_space_used_in_percent,16,2) as [avg_page_space_used(%)]from sys.dm_db_index_physical_stats(db_id(),object_id(@tab_name),default, default, 'detailed') ps    inner join sys.indexes ix on ix.object_id = ps.object_id and ix.index_id = ps.index_id    inner join sys.objects ob on ob.object_id=ix.object_idwhere ob.is_ms_shipped=0union all--外部碎片select '外部碎片' as frag_type    ,ob.name as object_name    ,ix.index_id,ix.name as index_name    ,ps.index_level    ,ps.partition_number    ,ps.record_count    ,ps.page_count    ,ps.fragment_count    ,str(ps.avg_fragmentation_in_percent,16,2) as [avg_frag(%)]    ,str(ps.avg_fragment_size_in_pages,16,1) as [avg_frag_pages]    ,ps.forwarded_record_count    ,ps.avg_record_size_in_bytes    ,str(ps.avg_page_space_used_in_percent,16,2) as [avg_page_space_used(%)]from sys.dm_db_index_physical_stats(db_id(),object_id(@tab_name),default, default, 'limited') ps    inner join sys.indexes ix on ix.object_id = ps.object_id and ix.index_id = ps.index_id    inner join sys.objects ob on ob.object_id=ix.object_idwhere ob.is_ms_shipped=0order by object_name,index_id,frag_type

转载地址:http://ofrdx.baihongyu.com/

你可能感兴趣的文章
多线程day01
查看>>
react-native 模仿原生 实现下拉刷新/上拉加载更多(RefreshListView)
查看>>
MySQL出现Access denied for user ‘root’@’localhost’ (using password:YES)
查看>>
通过Roslyn构建自己的C#脚本(更新版)(转)
查看>>
红黑树
查看>>
python调用windows api
查看>>
第四章 mybatis批量insert
查看>>
Java并发框架——什么是AQS框架
查看>>
【数据库】
查看>>
Win配置Apache+mod_wsgi+django环境+域名
查看>>
linux清除文件内容
查看>>
WindowManager.LayoutParams 详解
查看>>
find的命令的使用和文件名的后缀
查看>>
Android的Aidl安装方法
查看>>
Linux中rc的含义
查看>>
曾鸣:区块链的春天还没有到来| 阿里内部干货
查看>>
如何通过Dataworks禁止MaxCompute 子账号跨Project访问
查看>>
js之无缝滚动
查看>>
Django 多表联合查询
查看>>
logging模块学习:basicConfig配置文件
查看>>