MS SQL Узнать сколько места занимают индексы в БД

Скрипт отображает информацию о том, сколько в данной БД занимает каждый индекс:

USE DatabaseName
SELECT
OBJECT_NAME(i.OBJECT_ID) AS TableName,
i.name AS IndexName,
i.index_id AS IndexID,
8 * SUM(a.used_pages) AS 'Indexsize(KB)',
i.type AS IndexType,
i.type_desc AS IndexTypeDesc
FROM sys.indexes AS i
JOIN sys.partitions AS p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id
JOIN sys.allocation_units AS a ON a.container_id = p.partition_id
--WHERE OBJECT_NAME(i.OBJECT_ID) = 'TableName'
GROUP BY i.OBJECT_ID,i.index_id,i.name,i.type,i.type_desc
ORDER BY OBJECT_NAME(i.OBJECT_ID),i.index_id
0

Добавить комментарий

Ваш e-mail не будет опубликован.