The following query returns all indexes and their size (in MB) on your database. You can uncomment the where clause to determine the indexes size on any particular object.
SELECT OBJECT_SCHEMA_NAME(i.object_id) AS 'SchemaName', OBJECT_NAME(i.object_id) AS 'TableName', i.name AS 'IndexName', i.type_desc AS 'IndexType', CASE WHEN (i.[is_primary_key]) = 1 THEN 'PRIMARY KEY' WHEN (i.[is_unique]) = 1 THEN 'UNIQUE' WHEN (i.[is_unique]) = 0 THEN 'NON-UNIQUE' ELSE '' END AS 'ConstraintType', CONVERT(DECIMAL(10,2),(SUM(a.total_pages) * 8.00) / 1024.00) AS 'Size_MB' FROM sys.indexes i INNER JOIN sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE OBJECTPROPERTY(i.object_id, 'IsUserTable') = 1 AND i.name IS NOT NULL --AND object_name(i.Object_ID) = 'TAT_TIME' GROUP BY i.object_id, i.index_id, i.name, i.type_desc, i.[is_primary_key], i.[is_unique] ORDER BY 1,2,6 desc
Let’s see what the total indexes size is for each table. You can uncomment the where clause to determine the total indexes size on any particular object.
SELECT OBJECT_SCHEMA_NAME(i.object_id) AS 'SchemaName', OBJECT_NAME(i.object_id) AS 'TableName', CONVERT(DECIMAL(10,2),(SUM(a.total_pages) * 8.00) / 1024.00) AS 'Size_MB' FROM sys.indexes i INNER JOIN sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE OBJECTPROPERTY(i.object_id, 'IsUserTable') = 1 AND i.name IS NOT NULL --AND object_name(i.Object_ID) = 'TAT_TIME' GROUP BY i.object_id ORDER BY 1,2
References