sys.allocation_units , see total_pages. Each rowset (index section) has 3 allocation units (DATA, SLOB and LOB), see Table and organization of indexes . Join sys.partitions to get object_id and index_id. Index_id 0 is a bunch of unordered tables, index id 1 is a clustered index. Each table (index) has at least one partition, if not partitioned:
select object_name(p.object_id) as [name], object_schema_name(p.object_id) as [schema], i.name as [index], i.type_desc, au.type_desc, p.partition_number, p.rows, au.total_pages * 8 as [space (kb)] from sys.allocation_units au join sys.partitions p on au.container_id = p.partition_id join sys.indexes i on p.object_id = i. object_id and i.index_id = p.index_id order by [space (kb)] desc;
Remus Rusanu
source share