zoukankan      html  css  js  c++  java
  • 索引碎片情况,表行数,批整理脚本

    SELECT  objects.name ,
            indexes.name AS indexid ,
            avg_fragmentation_in_percent AS frag ,
            partition_stats.row_count,
            'ALTER INDEX '+indexes.name+' ON '+objects.name+' REBUILD  WITH (ONLINE = ON )'
    FROM    sys.dm_db_index_physical_stats(7, NULL, NULL, NULL, 'LIMITED') stats
            LEFT JOIN sys.objects objects ON stats.object_id = objects.object_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   avg_fragmentation_in_percent > 4
            AND stats.index_id > 0
    ORDER BY row_count DESC ,
            frag DESC

  • 相关阅读:
    load custom class in drupal 8
    HEAD in Git
    composer version constraint 版本号前缀
    如何测试
    看待一段数据
    创建一个plugin
    eclipse的快捷方式
    .git文件夹的猜想
    本地可以但远程不行
    方法点不进去的原因
  • 原文地址:https://www.cnblogs.com/qanholas/p/2424618.html
Copyright © 2011-2022 走看看