SQL server 数据库 读写状态统计语句

来源:互联网 发布:matlab 矩阵关联分析 编辑:程序博客网 时间:2024/06/05 17:08
--获取磁盘读写情况
select
  @@total_read as '读取磁盘的次数',
  @@total_write as '写入磁盘的次数',
  @@total_error as '磁盘写入错误数',
  getdate() as '当前时间'
 
--获取数据库文件的I/O统计信息
select from fn_virtualfilestats(null,null)
--两个参数
database_id--指定数据库编号,如果为null,则为所有数据库实例返回I/O统计信息
file_id --文件的编号,如果为null,则为所有文件返回信息
 
--获取I/O工作情况
select 
  @@id_busy,--SQL自上次启动以来的用于执行输入和输出操作的时间
  @@timeticks, --每个时钟周期对应的微秒数
  @@id_busy*@@timeticks as 'I/O 操作毫秒数',
  getdate() as '当前时间'
 
--查看SQL SEVER CPU活动,工作情况
select
  @@cpu_busy,--自上次启动以来的工作时间
  @@timeticks, --每个时钟周期对应的微秒数 
  @@cpu_busy*cast(@@timeticks as float)/1000 as 'cpu工作时间(秒)',
  @@idie*cast(@@timeticks as float)/1000 as 'CPU空闲时间(秒)'
  getdate() as '当前时间'
 
 
--获取网络数据包统计信息
select
  getdate() as '当前时间',
  @@pack_received as'输入数据包数量',
  @@pack_sent as '输出数据包数量',
  @@packet_error as '错误包数量'
0 0
原创粉丝点击