国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

SQL語句實現查詢Index使用狀況

2024-08-31 01:03:00
字體:
來源:轉載
供稿:網友

SELECTsch.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') = 1INNER JOIN sys.tablesAS t WITH (NOLOCK) ON i.object_id = t.object_idINNER JOIN sys.schemasAS sch WITH (NOLOCK) ON t.schema_id = sch.schema_idLEFT 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]

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新沂市| 河东区| 张掖市| 平江县| 澄江县| 永康市| 镇平县| 镇康县| 永定县| 盐边县| 苏州市| 获嘉县| 丽江市| 沁阳市| 柘荣县| 云和县| 普兰店市| 桃园县| 盈江县| 安多县| 柳江县| 和田市| 兴山县| 特克斯县| 邛崃市| 河津市| 古蔺县| 台江县| 乌兰察布市| 临夏市| 永登县| 麻阳| 卢龙县| 广平县| 南郑县| 衢州市| 宣威市| 安顺市| 龙江县| 武胜县| 盐池县|