728x90

SELECT  USER_NAME( OBJECTPROPERTY( i.id, 'OwnerID' ) ) AS Owner
   ,OBJECT_NAME( i.id ) AS [Table]
   , i.name AS [Index]
   ,CASE INDEXPROPERTY( i.id , i.name , 'IsClustered')  WHEN 1 THEN 'Y'  ELSE ''   END AS IsClustered
   ,CASE INDEXPROPERTY( i.id , i.name , 'IsUnique'    )  WHEN 1 THEN 'Y'  ELSE ''   END AS IsUnique
   ,STATS_DATE( i.id , i.indid ) AS LastUpdatedDate
   ,dPages * 8. /1024 AS MB
FROM sysindexes AS i
WHERE OBJECTPROPERTY( i.id, 'IsMSShipped' ) = 0
 AND 1 NOT IN ( INDEXPROPERTY( i.id , i.name , 'IsStatistics'   )
  , INDEXPROPERTY( i.id , i.name , 'IsAutoStatistics' )
  , INDEXPROPERTY( i.id , i.name , 'IsHypothetical'   )  )
 AND i.indid BETWEEN 1 And 250
-- AND dPages > 100 --작은 크기 테이블 무시
 AND (STATS_DATE( i.id , i.indid ) < getdate() - 15
  OR STATS_DATE( i.id , i.indid ) IS NULL) --15일 이전까지도 업데이트 안된 것
ORDER BY Owner, [Table], [Index]

[출처] 인덱스의 사용량|작성자 필립박

+ Recent posts