Search This Blog

Monday, 5 March 2012

SQL Server table index sizes

This will show the size of the indexes on a specific table

use MyDatabase
SELECT      i.name AS IndexName,
            SUM(s.used_page_count) * 8 AS IndexSizeKB
FROM        sys.dm_db_partition_stats AS s 
JOIN        sys.indexes AS i
ON          s.[object_id] = i.[object_id] AND s.index_id = i.index_id
WHERE       s.[object_id] = object_id('dbo.users')
GROUP BY    i.name
ORDER BY    i.name

Don't forget to substitute your own database name and table name!

No comments:

Post a Comment