码迷,mamicode.com
首页 > 数据库 > 详细

SQL SERVER查看索引使用情况

时间:2017-07-05 11:40:00      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:情况   tca   cat   表名   技术分享   png   --   object_id   nan   

SELECT DISTINCT
        DB_NAME() AS N‘db_name‘ ,
        E.name AS N‘schema_name‘ ,
        OBJECT_NAME(a.object_id) AS N‘table_name‘ ,
        b.name N‘index_name‘ ,
        user_seeks N‘seek‘ ,
        user_scans N‘scan‘ ,
        last_user_seek ,
        last_user_scan ,
        rows
FROM    sys.dm_db_index_usage_stats a
        INNER JOIN sys.indexes b ON a.index_id = b.index_id
                                   AND a.object_id = b.object_id
        INNER JOIN sysindexes c ON c.id = b.object_id
        INNER JOIN sys.objects D ON D.object_id = b.object_id
        INNER JOIN sys.schemas E ON D.schema_id = E.schema_id
WHERE   E.name = ‘Finance‘ --架构名
        --AND OBJECT_NAME(a.object_id) = ‘CostCenter‘--表名
        AND b.name = ‘IX_CostCategory_CnName‘ --索引名称
        AND rows <> 0;

 

技术分享

SQL SERVER查看索引使用情况

标签:情况   tca   cat   表名   技术分享   png   --   object_id   nan   

原文地址:http://www.cnblogs.com/qly2046/p/7119874.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!