码迷,mamicode.com
首页 > 其他好文 > 详细

How to resolve the truncate/drop/delete/join hang issue in ADW

时间:2016-12-10 06:43:25      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:exe   err   man   case   request   using   ret   command   sel   

In some case, we found that when we execute the sql commands like truncate table, drop table, delete all records in table, join 2 tables, it will take very very long time, and the execution is still in progress, no any result returned.

Probably it is caused by the sql connection to the table is in using by other sessions, so the solution is just need terminate those sessions by below sql script:

kill ‘SID295302‘

 

How to view all running sessions, and then find out the session id? Just need execute belows:

select top 200
(case when requests.status = ‘Completed‘ then 100
when progress.total_steps = 0 then 0
else 100 * progress.completed_steps / progress.total_steps end) as progress_percent,
requests.status,
requests.request_id,
sessions.login_name,
requests.start_time,
requests.end_time,
requests.total_elapsed_time,
requests.command,
errors.details,
requests.session_id,
(case when requests.resource_class is NULL then ‘N/A‘
else requests.resource_class end) as resource_class,
(case when resource_waits.concurrency_slots_used is NULL then ‘N/A‘
else cast(resource_waits.concurrency_slots_used as varchar(10)) end) as concurrency_slots_used

from sys.dm_pdw_exec_requests AS requests

join sys.dm_pdw_exec_sessions AS sessions
on (requests.session_id = sessions.session_id)
left join sys.dm_pdw_errors AS errors
on (requests.error_id = errors.error_id)
left join sys.dm_pdw_resource_waits AS resource_waits
on (requests.resource_class = resource_waits.resource_class)
outer apply (
select count (steps.request_id) as total_steps,
sum (case when steps.status = ‘Complete‘ then 1 else 0 end ) as completed_steps
from sys.dm_pdw_request_steps steps where steps.request_id = requests.request_id
) progress

where requests.start_time >= DATEADD(hour, -24, GETDATE()) and requests.status = ‘Running‘

ORDER BY requests.total_elapsed_time DESC, requests.start_time DESC

How to resolve the truncate/drop/delete/join hang issue in ADW

标签:exe   err   man   case   request   using   ret   command   sel   

原文地址:http://www.cnblogs.com/researcher/p/6152916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!