国产探花免费观看_亚洲丰满少妇自慰呻吟_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]

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 溧阳市| 大洼县| 松滋市| 上杭县| 金乡县| 潞城市| 曲水县| 彰武县| 东安县| 高碑店市| 龙江县| 台州市| 余干县| 和顺县| 威海市| 延吉市| 万盛区| 枞阳县| 灯塔市| 北辰区| 金湖县| 灯塔市| 巫山县| 云浮市| 泾阳县| 金沙县| 墨脱县| 桐柏县| 宝兴县| 白银市| 惠东县| 奉新县| 濮阳县| 香港| 江城| 崇义县| 启东市| 汕头市| 山阴县| 天气| 康马县|