patternsqlMinor
Can WAITFOR increase CXPACKET waits?
Viewed 0 times
canwaitsincreasewaitforcxpacket
Problem
If I have some T-SQL code like this:
Is this likely to increase waits for
While @done
EndIs this likely to increase waits for
CXPACKET? Presumably the other processor(s) will be waiting whilst WAITFOR is running?Solution
When you issue a
Likewise, when this task enters the suspended state it will get off of the scheduler (processor) so it won't be taking up worker time. We can see this with a simple example:
In another window you can run the following:
My results are as follows:
As for your question of how this will reflect in
But as said previously, the
WAITFOR command, the task will start having a wait_type of WAITFOR. This is a benign wait type and can be ignored.Likewise, when this task enters the suspended state it will get off of the scheduler (processor) so it won't be taking up worker time. We can see this with a simple example:
use AdventureWorks2012;
go
waitfor delay '00:10:00';
goIn another window you can run the following:
select
session_id,
command,
status,
wait_type
from sys.dm_exec_requests
where command = 'waitfor';My results are as follows:
session_id command status wait_type
54 WAITFOR suspended WAITFORAs for your question of how this will reflect in
sys.dm_os_wait_stats, upon the WAITFOR wait type's completion, it will then increment the WAITFOR type in sys.dm_os_wait_stats for the duration that the task was waiting for:select *
from sys.dm_os_wait_stats
where wait_type = 'waitfor';But as said previously, the
WAITFOR wait type is benign and can generally be ignored.Code Snippets
use AdventureWorks2012;
go
waitfor delay '00:10:00';
goselect
session_id,
command,
status,
wait_type
from sys.dm_exec_requests
where command = 'waitfor';session_id command status wait_type
54 WAITFOR suspended WAITFORselect *
from sys.dm_os_wait_stats
where wait_type = 'waitfor';Context
StackExchange Database Administrators Q#80324, answer score: 8
Revisions (0)
No revisions yet.