标签:
对数据的IO操作,都是写入到数据库文件中,sys.dm_io_virtual_file_stats Returns I/O statistics for data and log files.
sys.dm_io_virtual_file_stats (
{ database_id | NULL }
, { file_id | NULL }
)
io_stall:Total time, in milliseconds, that users waited for I/O to be completed on the file.
size_on_disk_bytes:Number of bytes used on the disk for this file.
查看数据库文件的IO和等待IO完成的时间
select vfs.database_id, vfs.file_id, mf.type_desc as file_type, vfs.sample_ms/1000/60/60 as duration_h, vfs.num_of_reads as reads, vfs.num_of_bytes_read/1024/1024 as read_mb, vfs.num_of_bytes_read/vfs.num_of_reads/1024 as avg_read_kb, vfs.io_stall_read_ms/vfs.num_of_reads as avg_stall_read_ms, vfs.num_of_writes as writes, vfs.num_of_bytes_written/1024/1024 as written_mb, vfs.num_of_bytes_written/vfs.num_of_writes/1024 as avg_writted_kb, vfs.io_stall_write_ms/vfs.num_of_writes as avg_stall_write_ms, vfs.io_stall/(vfs.num_of_reads+vfs.num_of_writes) as avg_stall_ms, cast(vfs.size_on_disk_bytes/1024/1024/1024.0 as decimal(10,2)) as disk_size_gb, cast(mf.size/1024*8/1024.0 as DECIMAL(10,2)) as file_size_gb, vfs.file_handle from sys.master_files mf CROSS APPLY sys.dm_io_virtual_file_stats(mf.database_id,mf.file_id) as vfs where mf.database_id=db_id() --current db order by avg_stall_read_ms desc ,avg_stall_write_ms desc
参考doc:
sys.dm_io_virtual_file_stats (Transact-SQL)
sys.master_files (Transact-SQL)
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5656233.html