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]
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐