zoukankan      html  css  js  c++  java
  • 索引,表增删改统计,加锁查具体情况(推荐)

     

     
     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

  • 相关阅读:
    第七章 过滤器 Filter(二)
    第七章 过滤器基础 Filter
    学了近一个月的java web 感想
    js写的一个简单的手风琴菜单
    第六章 对象作用域与servlet事件监听器
    第五章 Web应用程序状态管理
    第四章 使用Servlet处理HTTP请求
    第三章 使用Servlet处理HTTP响应
    第二章 Servlet基础
    myeclipse解决Fail to create the java Virtual Machine
  • 原文地址:https://www.cnblogs.com/qanholas/p/2424650.html
Copyright © 2011-2022 走看看