Site icon IT Tutorial

SQL Server Wait Events -2

Hi,

You should find that which of wait events are in the SQL Server database and status of currently waiting tasks.

 

Read previous article with following link

SQL Server Wait Events -1

 

 

To solve slowness of SQL Server database, you should find which wait events exists in the database.

 

You can get list and status of currently waiting tasks with following script.

 

select wt.session_id, wt.exec_context_id, wt.wait_duration_ms, wt.wait_type, wt.blocking_session_id, wt.resource_address, wt.resource_description, s.program_name, st.text, sp.query_plan, s.cpu_time cpu_time_ms, s.memory_usage*8 memory_usage_kb
from sys.dm_os_waiting_tasks wt
	join sys.dm_exec_sessions s on s.session_id=wt.session_id
	join sys.dm_exec_requests r on r.session_id=s.session_id
	outer apply sys.dm_exec_sql_text(r.sql_handle) st
	outer apply sys.dm_exec_query_plan(r.plan_handle) sp
where s.is_user_process=1
order by wt.session_id, wt.exec_context_id;

 

 

Do you want to learn Microsoft SQL Server DBA Tutorials for Beginners, then read the following articles.

https://ittutorial.org/sql-server-tutorials-microsoft-database-for-beginners/

Exit mobile version