Size of an Index

  • Hi,

    I need to know how much is the size of a particular index on a table.

    cheers

  • This is the code i use [lifted directly from MS]

    select object_name(i.object_id) as objectName, i.name as indexName,

    sum(a.total_pages) as totalPages, sum(a.used_pages) as usedPages, sum(a.data_pages) as dataPages,

    (sum(a.total_pages) * 8) / 1024 as totalSpaceMB, (sum(a.used_pages) * 8) / 1024 as usedSpaceMB, (sum(a.data_pages) * 8) / 1024 as dataSpaceMB

    from sys.indexes i

    join sys.partitions p

    on i.object_id = p.object_id

    and i.index_id = p.index_id

    join sys.allocation_units a

    on p.partition_id = a.container_id

    where i.object_id = object_id('YourTableNameGoesHere')

    group by i.object_id, i.index_id, i.name

  • thanks alot for the same.

    cheers

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply