博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
索引,表增删改统计,加锁查具体情况(推荐)
阅读量:5988 次
发布时间:2019-06-20

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

 

 
 SELECT databases.name ,
        objects.name ,
        indexes.name ,
        读写比例 = CAST(( range_scan_count + singleton_lookup_count ) AS DECIMAL(18,
                                                              2))
        / CASE WHEN CAST(( leaf_insert_count + leaf_update_count
                           + leaf_delete_count + nonleaf_insert_count
                           + nonleaf_update_count + nonleaf_delete_count ) AS DECIMAL(18,
                                                              2)) = 0 THEN 1
               ELSE CAST(( leaf_insert_count + leaf_update_count
                           + leaf_delete_count + nonleaf_insert_count
                           + nonleaf_update_count + nonleaf_delete_count ) AS DECIMAL(18,
                                                              2))
          END ,
        reads = range_scan_count + singleton_lookup_count ,
        writes = leaf_insert_count + leaf_update_count + leaf_delete_count
        + nonleaf_insert_count + nonleaf_update_count + nonleaf_delete_count ,
        leaf_insert_count ,
        leaf_update_count ,
        leaf_delete_count ,
        nonleaf_insert_count ,
        nonleaf_update_count ,
        nonleaf_delete_count ,
        range_scan_count ,
        singleton_lookup_count ,
        row_count ,
        page_lock_count ,
        partition_stats.row_count ,
        stats.*
 FROM   sys.dm_db_index_operational_stats(7, NULL, NULL, NULL) stats
        LEFT  JOIN sys.objects objects ON stats.object_id = objects.object_id
        LEFT  JOIN sys.databases databases ON databases.database_id = stats.database_id
        LEFT  JOIN sys.indexes indexes ON indexes.index_id = stats.index_id
                                          AND stats.object_id = indexes.object_id
        LEFT   JOIN sys.dm_db_partition_stats partition_stats ON stats.object_id = partition_stats.object_id
                                                              AND indexes.index_id = partition_stats.index_id
 WHERE  objects.name NOT LIKE 'sys%'
 ORDER BY row_count DESC

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

你可能感兴趣的文章
magento 通过程序创建客户和订单
查看>>
成功路上,谁不会跌跌碰碰!
查看>>
Mac OS X 恢复 VMware Fusion 虚拟机中的 vmdk 文件
查看>>
搭建cocos2d 2.2-x环境及创建工程
查看>>
PowerShell
查看>>
yinyuetai.com音悦台 80万数据采集
查看>>
asp.net log4net的使用
查看>>
rsync注意
查看>>
git-自动化脚本
查看>>
配置别名
查看>>
动态加载JS文件
查看>>
Active Directory 活动目录之强制占有操作主机
查看>>
python中List添加元素的几种方法
查看>>
搭建基于虚拟用户的电子邮件服务器
查看>>
VS2015中C#连接Oracle数据库
查看>>
C#学习速记_面向对象编程简介
查看>>
WSS3.0 和 MOSS 的版本号小结
查看>>
我的友情链接
查看>>
对Class.getResourceAsStream和ClassLoader.getResourceAsStream方法所使用的资源路径的解释...
查看>>
Lync Server 2013服务器准备林架构报错
查看>>