mssql sqlserver 查询 指定服务器下各数据文件的io使用情况


摘要:
下文将讲述使用sql脚本获取当前服务器下数据库文件的IO使用情况
实验环境:sql server 2008 R2


------------------------------------
    SELECT  
c.database_id AS [数据库ID],  
c.name AS [数据库名称],  
b.name AS [逻辑文件名],  
b.type_desc AS [文件类型],  
CAST(a.num_of_bytes_read/1024.0/1024.0 AS INT) AS [读总额M],  
CAST(a.num_of_bytes_written /1024.0/1024.0 AS INT) AS [写总额M],  
a.num_of_reads,  
a.num_of_writes,  
a.io_stall_read_ms,  
a.io_stall_write_ms,  
a.io_stall,  
CAST(a.size_on_disk_bytes/1024.0/1024.0 AS INT) AS [数据库大小]  
FROM sys.dm_io_virtual_file_stats(NULL,NULL) AS a  
inner JOIN sys.master_files b  
ON a.database_id=b.database_id and a.file_id=b.file_id  
inner JOIN sys.databases c  
ON a.database_id=c.database_id  
------------------------------------
mssql_sqlserver_数据库文件io查看方法

mssql_sqlserver_数据库文件io查看方法