SqlServer 查看 数据库 对于IO 的消耗
【代码】SqlServer 查看 数据库 对于IO 的消耗。
·
SELECT
ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank],
[DB Name],
io_in_mb AS [Total I/O (MB)],
CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [Total I/O%],
CAST(read_in_mb/ SUM(read_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [Total Read%],
CAST(write_in_mb/ SUM(write_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [Total Write%]
FROM
(
SELECT DB_NAME(database_id) AS [DB Name],
CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb,
CAST(SUM(num_of_bytes_read)/1048576 AS DECIMAL(12, 2)) AS read_in_mb,
CAST(SUM(num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS write_in_mb
FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS]
GROUP BY database_id
) AggregateIOStatistics
ORDER BY [I/O Rank]
更多推荐
已为社区贡献2条内容
所有评论(0)