最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SQL語句實現(xiàn)查詢Index使用狀況

 更新時間:2015年07月07日 10:52:35   投稿:junjie  
這篇文章主要介紹了SQL語句實現(xiàn)查詢Index使用狀況,本文直接給出SQL腳本代碼,需要的朋友可以參考下
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]

相關(guān)文章

最新評論

渑池县| 康马县| 台江县| 滁州市| 章丘市| 武威市| 灵山县| 新干县| 平安县| 宿迁市| 抚远县| 凤翔县| 腾冲县| 福建省| 临颍县| 金寨县| 建宁县| 建平县| 博野县| 奇台县| 宜兴市| 大名县| 凤庆县| 邵东县| 澄城县| 沂源县| 嫩江县| 阿合奇县| 鹤壁市| 乡城县| 内黄县| 农安县| 平凉市| 石狮市| 聂拉木县| 榆中县| 杂多县| 阜阳市| 南漳县| 饶河县| 桃江县|