SELECT
   sch.name + '.' + t.name AS [Table Name],
   i.name AS[Index Name],
   i.type_desc, 
   ISNULL(user_updates,0) AS [Total Writes],
   ISNULL(user_seeks +user_scans + user_lookups,0) AS [Total Reads],
   s.last_user_seek,
   s.last_user_scan ,
   s.last_user_lookup,
   ISNULL(user_updates,0) - ISNULL((user_seeks+ user_scans +user_lookups),0)AS [Difference], 
   p.reserved_page_count * 8.0 / 1024 as SpaceInMB
FROM sys.indexes AS i WITH (NOLOCK) 
   LEFT OUTERJOIN sys.dm_db_index_usage_statsAS s   WITH (NOLOCK) ON s.object_id = i.object_id AND i.index_id = s.index_id AND s.database_id=db_id() AND objectproperty(s.object_id,'IsUserTable') = 1 
   INNER JOIN    sys.tables             AS t WITH (NOLOCK) ON i.object_id = t.object_id 
   INNER JOIN    sys.schemas             AS sch   WITH (NOLOCK) ON t.schema_id = sch.schema_id 
   LEFT OUTERJOIN sys.dm_db_partition_stats AS p WITH (NOLOCK) ON i.index_id = p.index_id and i.object_id = p.object_id
WHERE (1=1)
   --AND ISNULL(user_updates,0) >=ISNULL((user_seeks + user_scans + user_lookups),0) --shows all indexesincluding those that have not been used 
   --AND ISNULL(user_updates,0) -ISNULL((user_seeks + user_scans + user_lookups),0)>0 --only shows thoseindexes which have been used 
   --AND i.index_id > 1        -- Only non-first indexes (I.E.non-primary key)
   --AND i.is_primary_key<>1     -- Only those that are not defined asa Primary Key)
   --AND i.is_unique_constraint<>1-- Only those that are not classed as "UniqueConstraints". 
ORDER BY [Table Name],[index name]
标签:
SQL,语句,查询,Index,使用状况

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
评论“SQL语句实现查询Index使用状况”
暂无“SQL语句实现查询Index使用状况”评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。