查找SQL SERVER 2005 IO过高的数据库

ExpandedBlockStart.gif 代码
with  DB_IO  as  (
select  
    
db_name (a.database_id)  as   [ dbname ] ,
    
case   when  b.type_desc = ' LOG '   then   ' LogFile '   else   ' DataFile '   end   as  FileType,
    num_of_reads,
    num_of_writes,
    
sum (a.io_stall)  as  io_stall,
    
sum (num_of_bytes_read + num_of_bytes_written)  as  TotalIOBytes
from  sys.dm_io_virtual_file_stats( null , null ) a  join  sys.master_files b 
on  a.database_id = b.database_id  and  a. file_id = b. file_id
group   by   db_name (a.database_id),b.type_desc,num_of_reads,num_of_writes
)
select  
    dbname,
    FileType,
    num_of_reads,
    num_of_writes,
    
cast ( 1 *  TotalIOBytes / ( 1024 * 1024 as   decimal ( 12 , 2 ))  as  IO_MB,
    
cast ( 1 *  io_stall / 1000   as   decimal ( 12 , 2 ))  as  IO_stall_s,
    
cast ( 100 *  io_stall / sum (io_stall)  over ()  as   decimal ( 10 , 2 ))  as   [ IO_stall_pct% ] , -- 占总IO的百分比
    row_number()  over ( order   by  io_stall  desc as  rn
from  DB_IO

 

如图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值