主頁 > 知識(shí)庫 > SQL語句實(shí)現(xiàn)查詢Index使用狀況

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

熱門標(biāo)簽:真人語音電銷機(jī)器人 洛陽外呼系統(tǒng)平臺(tái) 廣州人工電銷機(jī)器人費(fèi)用 400外呼系統(tǒng)合法 寧波人工外呼系統(tǒng)有效果嗎 地圖標(biāo)注一個(gè)圓圈怎么用 電銷機(jī)器人被曝光 怎樣把地圖標(biāo)注導(dǎo)入公司地址 如何在地圖標(biāo)注自己店鋪
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]

標(biāo)簽:石家莊 北海 晉中 南昌 煙臺(tái) 咸寧 東營 珠海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《SQL語句實(shí)現(xiàn)查詢Index使用狀況》,本文關(guān)鍵詞  SQL,語句,實(shí)現(xiàn),查詢,Index,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《SQL語句實(shí)現(xiàn)查詢Index使用狀況》相關(guān)的同類信息!
  • 本頁收集關(guān)于SQL語句實(shí)現(xiàn)查詢Index使用狀況的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章