香港云主机最佳企业级服务商!

ADSL拨号VPS包含了中国大陆(联通,移动,电信,)

中国香港,国外拨号VPS。

当前位置:云主机 > MSSQL >

电信ADSL拨号VPS
联通ADSL拨号VPS
移动ADSL拨号VPS

SQL语句实现查询Index使用状况


时间:2020-10-31 14:28 作者:admin


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 SpaceInMBFROM 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_idWHERE (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]
(责任编辑:admin)






帮助中心
会员注册
找回密码
新闻中心
快捷通道
域名登录面板
虚机登录面板
云主机登录面板
关于我们
关于我们
联系我们
联系方式

售前咨询:17830004266(重庆移动)

企业QQ:383546523

《中华人民共和国工业和信息化部》 编号:ICP备00012341号

Copyright © 2002 -2018 香港云主机 版权所有
声明:香港云主机品牌标志、品牌吉祥物均已注册商标,版权所有,窃用必究

云官方微信

在线客服

  • 企业QQ: 点击这里给我发消息
  • 技术支持:383546523

  • 公司总台电话:17830004266(重庆移动)
  • 售前咨询热线:17830004266(重庆移动)