Sie sind auf Seite 1von 1

Themostimportantinformationwhichsys.dm_exec_requestscangiveisthepercent_complete.

Thecolumn
percent_completeandestimated_completion_timeiscalculatedbasedonthecurrentprogressoftherequest.
Thesevaluesarevalidforonlycertainsetofrequests.Theseincludecommandslikebackup,restore,
recovery,shrink,checkdb,checktable,indexreorganize,rollback,TDEencryption,etc.Youcanusethebelow
commandtotracktheprogressofanyoftheaboveoperation.
1 SELECTpercent_complete,
2
estimated_completion_time/1000/60.00ASest_min
3 FROMsys.dm_exec_requestsWHEREsession_id=<spid>

Sys.dm_exec_requestsincombinationwithsys.dm_exec_sessionscanbeusedtotroubleshoototherissues
likeblocking.ThescopeofthisDMVusageisbroadandcanonlybeexploredonusage.SoIwillleavethe
imaginationofitsusagetoyourDBbrains.Belowisonequeryyoucanusetodetectleadblockerincaseof
blocking.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

WITHbAS
(

SELECTdistinctblocking_session_idASblockers

FROMsys.dm_exec_requests
)
SELECTsession_id,

0ASblocking_session_id,

Block_Desc='Lead'
FROMsys.dm_exec_sessionses
INNERJOINb

ONes.session_id=b.blockers
WHERENOTEXISTS(SELECT1FROMsys.dm_exec_requests

OREXISTS(SELECT1FROMsys.dm_exec_requestser

UNIONALL

SELECTsession_id,

blocking_session_id,

Block_Desc='Victim'
FROMsys.dm_exec_requests
WHEREblocking_session_id!=0

IntheabovequeryIhaveusedtwoconditionsintheWHEREclause.Canyouguesswhy?Itisbecausea
sessioncancauseblockingwithanopentransaction.Therequestmayhavebeencompletedbutitisstillnot
committed.Thisdoesnotshowupinsys.dm_exec_requests.ForexampleintheabovecaseIhaverunthe
belowcommandsinsession57and56tocreatetheblocking.Youcancheckwhentheblockingishappeningin
sys.dm_exec_requestsand57willnotshowup.
1
2
3
4
5
6
7
8

Session57LeadBlocker
BEGINTRAN
UPDATEtest

SETid=5
WHEREid=4

Session56Victim
SELECT*FROMtest

TransactSQL

Das könnte Ihnen auch gefallen