gpt4 book ai didi

sql-server - SQL Server : Number of 8K Pages Used by a Table and/or Database

转载 作者:行者123 更新时间:2023-12-02 07:26:27 25 4
gpt4 key购买 nike

我可以使用 T-SQL 来显示表用于存储其行的 8K 页数吗?

另外,我可以查看数据库正在使用的 8K 页数吗?

最佳答案

尝试这样的事情:

-- Total # of pages, used_pages, and data_pages for a given heap/clustered index
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) AS TotalPages,
SUM(a.used_pages) AS UsedPages,
(SUM(a.total_pages) - SUM(a.used_pages)) AS UnusedPages
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.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
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name

这会显示表格使用的页面 - 已使用、未使用和总计。

对于整个数据库 - 只需总结每个表的页数并对每个数据库重复即可。

关于sql-server - SQL Server : Number of 8K Pages Used by a Table and/or Database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11946957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com