查询SQL server 对象存储信息

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
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
GROUP BY i.object_id,
        i.index_id,
        i.name
ORDER BY SUM(a.total_pages) DESC,
        OBJECT_NAME(i.object_id); 

 

查询SQL server 对象存储信息

上一篇:揭秘一条select语句,在MySQL中权限访问控制内幕


下一篇:你们一般都是怎么进行SQL调优的?MySQL在执行时是如何选择索引的?