Сколько занимает место индексы

Tsql теория > Сколько занимает место индексы
10.12.2018 21:34:30


Наиболее часто встречающиеся слова в статье:

[object_id] [total_pages] [used_pages] [index_id] [schema_id] [ObjectName] [SchemaName] [RowCounts] [TotalSpaceKB] [UsedSpaceKB]


Статья:

select 
    o.Name as ObjectName,
    s.Name as SchemaName,
    p.rows as RowCounts,
    SUM(a.total_pages) * 8 as TotalSpaceKB, 
    SUM(a.used_pages) * 8 as UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 as UnusedSpaceKB
from sys.objects o
inner join sys.indexes i on o.object_id = i.object_id
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
left join sys.schemas s on o.schema_id = s.schema_id
where o.is_ms_shipped = 0
and o.Name = имя  таблицы''
group by o.Name, s.Name, p.Rows
order by o.Name