This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], | |
i.index_id, user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], | |
user_updates - (user_seeks + user_scans + user_lookups ) AS [Difference] | |
FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) | |
INNER JOIN sys.indexes AS i WITH (NOLOCK) | |
ON s.[object_id] = i.[object_id] | |
AND i.index_id = s.index_id | |
WHERE OBJECTPROPERTY(s.[object_id], 'IsUserTable') = 1 | |
AND s.database_id = DB_ID() | |
AND user_updates > (user_seeks + user_scans + user_lookups) | |
AND i.index_id > 1 | |
ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE) |
인덱스를 과도하게 많이 생성할 경우 insert 작업의 성능이 저하될 수 있다.
위 쿼리를 이용해 인덱스가 사용된 수와 관리되어야 하는 인덱스 수를 비교해보면 인덱스가 사용되는 것인지 아닌지를 판별할 수 있다.
1. 실전 SQLServerMVP61 - Part01. 03 - 구조적 성장의 고통
'SQL' 카테고리의 다른 글
MSSQL MERGE (UPSERT) (276) | 2020.10.19 |
---|---|
[MSSQL] 캐시된 실행계획에서 누락된 인덱스 정보를 가지고 있는 개체 찾기 (761) | 2020.09.21 |
[MSSQL] 누락된 인덱스 찾기 (444) | 2020.09.21 |
SQL 변수 선언 및 사용 (2) | 2016.05.19 |
GROUP BY 및 HAVING 그리고 집계 함수 (2) | 2016.05.19 |
댓글