IO相關SQL

1. 查找 I/O 閂鎖等待統計信息

select wait_type, waiting_tasks_count, wait_time_ms, signal_wait_time_ms, wait_time_ms / waiting_tasks_count
from sys.dm_os_wait_stats  
where wait_type like 'PAGEIOLATCH%'  and waiting_tasks_count > 0
order by wait_type

如果 waiting_task_countswait_time_ms 與正常情況相比有顯著變化,則可以確定存在 I/O 問題。

2. 查找當前掛起的 I/O 請求

select database_id, file_id, io_stall, io_pending_ms_ticks, scheduler_address
from  sys.dm_io_virtual_file_stats(NULL, NULL)t1, sys.dm_io_pending_io_requests as t2
where t1.file_handle = t2.io_handle
在正常情況下,該查詢通常不返回任何內容。如果此查詢返回一些行,則需要進一步調查。

3. 平均IO最多的5個SQL
select top 5 (total_logical_reads/execution_count) as avg_logical_reads,(total_logical_writes/execution_count) as avg_logical_writes,
            (total_physical_reads/execution_count) as avg_physical_reads, Execution_count, statement_start_offset, p.query_plan, q.text
from sys.dm_exec_query_stats cross apply sys.dm_exec_query_plan(plan_handle) p cross apply sys.dm_exec_sql_text(plan_handle) as q
order by (total_logical_reads + total_logical_writes)/execution_count Desc


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章