November 22, 2012 at 2:03 pm
I look forward to it 🙂
Oddly it wasnt that the numbers were different. It was that the waits were entirely different. There wasn't any overlap between the two scripts. Your script looked like this:
WRITELOG7168331141587429
CXPACKET1727229412899940
ASYNC_NETWORK_IO20313663974649
PAGEIOLATCH_SH37109653626942
PAGEIOLATCH_EX688979436225
ASYNC_IO_COMPLETION299297143
IO_COMPLETION415738212294
PAGELATCH_EX23683964209939
SOS_SCHEDULER_YIELD5274174136505
LATCH_EX23642071269
Glenn's looked like this:
wait_typewait_time_spctrunning_pct
SQLTRACE_INCREMENTAL_FLUSH_SLEEP1490310.3938.2838.28
BROKER_EVENTHANDLER1434896.1336.8675.14
ONDEMAND_TASK_QUEUE887224.0422.7997.94
Notice no overlap in wait types...
Both scripts are awesome in their own way and I look forward to all of the inovation and inginuity that goes into each person's version.
Best,
Tony
November 23, 2012 at 12:24 pm
Hi Tony,
I haven't seen Glenn's code so I can't comment on it. My code reads from sys.dm_os_wait_stats and then produces a report from the top 10 in descending order.
As you can see, it basic and is data collected by Microsoft SQL server.
Not sure what else I can say.
Thanks again!
Rudy
Rudy
November 26, 2012 at 9:02 am
Thanks for taking the time to post this script. I find the "Possible Issues" column very useful. Spurred me to take the time to find updated firmware for my disk array.
November 26, 2012 at 9:14 am
ahperez (11/26/2012)
Thanks for taking the time to post this script. I find the "Possible Issues" column very useful. Spurred me to take the time to find updated firmware for my disk array.
Great! I'm glad the code is helping out. That's what I was hoping for.
Rudy
Rudy
November 26, 2012 at 9:27 am
I'm not sure why I got carried away with this, but I modified your script as shown below. It should provide the same results. The main changes were to take out the cursor and all those UPDATE statements. Instead of that I created another temp table to join against.
USE MASTER
SET NOCOUNT ON
CREATE TABLE #wait_stats (
wait_type nvarchar(60) NOT NULL
,waiting_tasks_count bigint NOT NULL
,wait_time_ms bigint NOT NULL
,max_wait_time_ms bigint NOT NULL
,signal_wait_time_ms bigint NOT NULL
)
CREATE TABLE #wait_type (
wait_type nvarchar(60) NOT NULL
,comment varchar(max) NOT NULL
)
INSERT INTO #wait_stats (
wait_type
,waiting_tasks_count
,wait_time_ms
,max_wait_time_ms
,signal_wait_time_ms
)
SELECT
wait_type
,waiting_tasks_count
,wait_time_ms
,max_wait_time_ms
,signal_wait_time_ms
FROM
sys.dm_os_wait_stats
WHERE
waiting_tasks_count <> 0
INSERT INTO #wait_type (
wait_type
,comment
)
SELECT 'SOS_SCHEDULER_YIELD' , 'CPU - Execute this script: SELECT scheduler_id, current_tasks_count, runnable_tasks_count FROM sys.dm_os_schedulers WHERE scheduler_id < 255 ;If runnable tasks count > zero, CPU issues if double digits for any length of time, extreme CPU concern'
UNION ALL SELECT 'CXPACKET' , 'SETTINGS OR CODE - Wait stats shows more than 5% of your waits are on CXPackets, you may want to test lower (or non-zero) values of “max degree of parallelism”. Never set value great than # of CPUs'
UNION ALL SELECT 'ASYNC_NETWORK_IO' , 'NETWORK - Occurs on network writes when the task is blocked behind the network'
UNION ALL SELECT 'LCK_M_BU' , 'LOCK - Waiting to acquire a Bulk Update (BU) lock'
UNION ALL SELECT 'LCK_M_IS' , 'LOCK - Waiting to acquire an Intent Shared (IS) lock'
UNION ALL SELECT 'LCK_M_IU' , 'LOCK - Waiting to acquire an Intent Update (IU) lock '
UNION ALL SELECT 'LCK_M_IX' , 'LOCK - Waiting to acquire an Intent Exclusive (IX) lock'
UNION ALL SELECT 'LCK_M_RIn_NL' , 'LOCK - Waiting to acquire a NULL lock on the current key value and an Insert Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RIn_S' , 'LOCK - Waiting to acquire a shared lock on the current key value and an Insert Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RIn_U' , 'LOCK - Waiting to acquire an Update lock on the current key value, and an Insert Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RIn_X' , 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Insert Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RS_S' , 'LOCK - Waiting to acquire a Shared lock on the current key value, and a Shared Range lock between the current and previous'
UNION ALL SELECT 'LCK_M_RS_U' , 'LOCK - Waiting to acquire an Update lock on the current key value, and an Update Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RX_S' , 'LOCK - Waiting to acquire a Shared lock on the current key value, and an Exclusive Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RX_U' , 'LOCK - Waiting to acquire an Update lock on the current key value, and an Exclusive range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_RX_X' , 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Exclusive Range lock between the current and previous key'
UNION ALL SELECT 'LCK_M_S' , 'LOCK - Waiting to acquire a Shared lock'
UNION ALL SELECT 'LCK_M_SCH_M' , 'LOCK - Waiting to acquire a Schema Modify lock'
UNION ALL SELECT 'LCK_M_SCH_S' , 'LOCK - Waiting to acquire a Schema Modify lock'
UNION ALL SELECT 'LCK_M_SIU' , 'LOCK - Waiting to acquire a Shared With Intent Update lock'
UNION ALL SELECT 'LCK_M_SIX' , 'LOCK - Waiting to acquire a Shared With Intent Exclusive lock'
UNION ALL SELECT 'LCK_M_U' , 'LOCK - Waiting to acquire an Update lock'
UNION ALL SELECT 'LCK_M_UIX' , 'LOCK - Waiting to acquire an Update With Intent Exclusive lock'
UNION ALL SELECT 'LCK_M_X' , 'LOCK - Waiting to acquire an Exclusive lock'
UNION ALL SELECT 'LATCH_DT' , 'LOCK - Waiting for a DT (destroy) latch. This does not include buffer latches or transaction mark latches'
UNION ALL SELECT 'LATCH_EX' , 'LOCK - Waiting for an EX (exclusive) latch. This does not include buffer latches or transaction mark latches'
UNION ALL SELECT 'LATCH_KP' , 'LOCK - Waiting for a KP (keep) latch. This does not include buffer latches or transaction mark latches'
UNION ALL SELECT 'LATCH_SH' , 'LOCK - Waiting for an SH (share) latch. This does not include buffer latches or transaction mark latches'
UNION ALL SELECT 'LATCH_UP' , 'LOCK - Waiting for an UP (update) latch. This does not include buffer latches or transaction mark latches'
UNION ALL SELECT 'RESOURCE_SEMAPHORE' , 'MEMORY - Query memory request cannot be granted immediately due to other concurrent queries. High waits and wait times may indicate excessive number of concurrent queries, or excessive memory request amounts'
UNION ALL SELECT 'RESOURCE_SEMAPHORE_MUTEX' , 'MEMORY - Query waits for its request for a thread reservation to be fulfilled. It also occurs when synchronizing query compile and memory grant requests'
UNION ALL SELECT 'RESOURCE_SEMAPHORE_QUERY_COMPILE' , 'MEMORY - Number of concurrent query compilations reaches a throttling limit. High waits and wait times may indicate excessive compilations, recompiles, or uncachable plans'
UNION ALL SELECT 'RESOURCE_SEMAPHORE_SMALL_QUERY' , 'MEMORY - Memory request by a small query cannot be granted immediately due to other concurrent queries. Wait time should not exceed more than a few seconds. High waits may indicate an excessive number of concurrent small queries while the main memory pool is blocked by waiting queries'
UNION ALL SELECT 'WRITELOG' , 'MEMORY - Waiting for a log flush to complete. Common operations that cause log flushes are checkpoints and transaction commits'
UNION ALL SELECT 'PAGEIOLATCH_DT' , 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Destroy mode. Long waits may indicate problems with the disk subsystem'
UNION ALL SELECT 'PAGEIOLATCH_EX' , 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Exclusive mode. Long waits may indicate problems with the disk subsystem'
UNION ALL SELECT 'PAGEIOLATCH_KP' , 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Keep mode. Long waits may indicate problems with the disk subsystem'
UNION ALL SELECT 'PAGEIOLATCH_SH' , 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Share mode. Long waits may indicate problems with the disk subsystem'
UNION ALL SELECT 'PAGEIOLATCH_UP' , 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Update mode. Long waits may indicate problems with the disk subsystem'
UNION ALL SELECT 'PAGELATCH_DT' , 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Destroy mode'
UNION ALL SELECT 'PAGELATCH_EX' , 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Exclusive mode'
UNION ALL SELECT 'PAGELATCH_KP' , 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Keep mode'
UNION ALL SELECT 'PAGELATCH_SH' , 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Shared mode'
UNION ALL SELECT 'PAGELATCH_UP' , 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Update mode'
UNION ALL SELECT 'LOGBUFFER' , 'DISK - Waiting for space in the log buffer to store a log record. Consistently high values may indicate that the log devices cannot keep up with the amount of log being generated by the server'
UNION ALL SELECT 'ASYNC_IO_COMPLETION' , 'DISK - Waiting for I/Os to finish'
UNION ALL SELECT 'IO_COMPLETION' , 'DISK - Waiting for I/O operations to complete. This wait type generally represents non-data page I/Os. Data page I/O completion waits appear as PAGEIOLATCH_* waits'
SELECT TOP 10
'OS WAIT STATS - WAIT TYPE' = ws.wait_type
,'TASKS WAITING COUNT' = ws.waiting_tasks_count
,'TIME WAITING (MS)' = ws.wait_time_ms
,'MAX TIME WAITING (MS)' = ws.max_wait_time_ms
,'SIGNAL TIME WAITING (MS)' = ws.signal_wait_time_ms
,'POSSIBLE ISSUES' = wt.comment
FROM
#wait_stats ws
INNER JOIN
#wait_type wt ON (ws.wait_type = wt.wait_type)
ORDER BY
ws.wait_time_ms DESC
DROP TABLE #wait_stats
DROP TABLE #wait_type
November 26, 2012 at 9:47 am
Why do you need the temporary tables?
SELECT TOP 10
[OS WAIT STATS - WAIT TYPE] = a.wait_type,
[TASKS WAITING COUNT] = a.waiting_tasks_count,
[TIME WAITING (MS)] = a.wait_time_ms,
[MAX TIME WAITING (MS)] = a.max_wait_time_ms,
[SIGNAL TIME WAITING (MS)] = a.signal_wait_time_ms,
[POSSIBLE ISSUES] = b.comment
FROM (SELECT wait_type, waiting_tasks_count,
wait_time_ms, max_wait_time_ms,
signal_wait_time_ms
FROM sys.dm_os_wait_stats
WHERE waiting_tasks_count <> 0
) a
INNER JOIN (SELECT wait_type, comment
FROM (SELECT 'SOS_SCHEDULER_YIELD',
'CPU - Execute this script: SELECT scheduler_id, current_tasks_count, runnable_tasks_count FROM sys.dm_os_schedulers WHERE scheduler_id < 255 ;If runnable tasks count > zero, CPU issues if double digits for any length of time, extreme CPU concern'
UNION ALL
SELECT 'CXPACKET',
'SETTINGS OR CODE - Wait stats shows more than 5% of your waits are on CXPackets, you may want to test lower (or non-zero) values of “max degree of parallelism”. Never set value great than # of CPUs'
UNION ALL
SELECT 'ASYNC_NETWORK_IO', 'NETWORK - Occurs on network writes when the task is blocked behind the network'
UNION ALL
SELECT 'LCK_M_BU', 'LOCK - Waiting to acquire a Bulk Update (BU) lock'
UNION ALL
SELECT 'LCK_M_IS', 'LOCK - Waiting to acquire an Intent Shared (IS) lock'
UNION ALL
SELECT 'LCK_M_IU', 'LOCK - Waiting to acquire an Intent Update (IU) lock '
UNION ALL
SELECT 'LCK_M_IX', 'LOCK - Waiting to acquire an Intent Exclusive (IX) lock'
UNION ALL
SELECT 'LCK_M_RIn_NL', 'LOCK - Waiting to acquire a NULL lock on the current key value and an Insert Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RIn_S', 'LOCK - Waiting to acquire a shared lock on the current key value and an Insert Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RIn_U', 'LOCK - Waiting to acquire an Update lock on the current key value, and an Insert Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RIn_X', 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Insert Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RS_S', 'LOCK - Waiting to acquire a Shared lock on the current key value, and a Shared Range lock between the current and previous'
UNION ALL
SELECT 'LCK_M_RS_U', 'LOCK - Waiting to acquire an Update lock on the current key value, and an Update Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RX_S', 'LOCK - Waiting to acquire a Shared lock on the current key value, and an Exclusive Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RX_U', 'LOCK - Waiting to acquire an Update lock on the current key value, and an Exclusive range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_RX_X', 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Exclusive Range lock between the current and previous key'
UNION ALL
SELECT 'LCK_M_S', 'LOCK - Waiting to acquire a Shared lock'
UNION ALL
SELECT 'LCK_M_SCH_M', 'LOCK - Waiting to acquire a Schema Modify lock'
UNION ALL
SELECT 'LCK_M_SCH_S', 'LOCK - Waiting to acquire a Schema Modify lock'
UNION ALL
SELECT 'LCK_M_SIU', 'LOCK - Waiting to acquire a Shared With Intent Update lock'
UNION ALL
SELECT 'LCK_M_SIX', 'LOCK - Waiting to acquire a Shared With Intent Exclusive lock'
UNION ALL
SELECT 'LCK_M_U', 'LOCK - Waiting to acquire an Update lock'
UNION ALL
SELECT 'LCK_M_UIX', 'LOCK - Waiting to acquire an Update With Intent Exclusive lock'
UNION ALL
SELECT 'LCK_M_X', 'LOCK - Waiting to acquire an Exclusive lock'
UNION ALL
SELECT 'LATCH_DT', 'LOCK - Waiting for a DT (destroy) latch. This does not include buffer latches or transaction mark latches'
UNION ALL
SELECT 'LATCH_EX', 'LOCK - Waiting for an EX (exclusive) latch. This does not include buffer latches or transaction mark latches'
UNION ALL
SELECT 'LATCH_KP', 'LOCK - Waiting for a KP (keep) latch. This does not include buffer latches or transaction mark latches'
UNION ALL
SELECT 'LATCH_SH', 'LOCK - Waiting for an SH (share) latch. This does not include buffer latches or transaction mark latches'
UNION ALL
SELECT 'LATCH_UP', 'LOCK - Waiting for an UP (update) latch. This does not include buffer latches or transaction mark latches'
UNION ALL
SELECT 'RESOURCE_SEMAPHORE',
'MEMORY - Query memory request cannot be granted immediately due to other concurrent queries. High waits and wait times may indicate excessive number of concurrent queries, or excessive memory request amounts'
UNION ALL
SELECT 'RESOURCE_SEMAPHORE_MUTEX', 'MEMORY - Query waits for its request for a thread reservation to be fulfilled. It also occurs when synchronizing query compile and memory grant requests'
UNION ALL
SELECT 'RESOURCE_SEMAPHORE_QUERY_COMPILE',
'MEMORY - Number of concurrent query compilations reaches a throttling limit. High waits and wait times may indicate excessive compilations, recompiles, or uncachable plans'
UNION ALL
SELECT 'RESOURCE_SEMAPHORE_SMALL_QUERY',
'MEMORY - Memory request by a small query cannot be granted immediately due to other concurrent queries. Wait time should not exceed more than a few seconds. High waits may indicate an excessive number of concurrent small queries while the main memory pool is blocked by waiting queries'
UNION ALL
SELECT 'WRITELOG', 'MEMORY - Waiting for a log flush to complete. Common operations that cause log flushes are checkpoints and transaction commits'
UNION ALL
SELECT 'PAGEIOLATCH_DT', 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Destroy mode. Long waits may indicate problems with the disk subsystem'
UNION ALL
SELECT 'PAGEIOLATCH_EX', 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Exclusive mode. Long waits may indicate problems with the disk subsystem'
UNION ALL
SELECT 'PAGEIOLATCH_KP', 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Keep mode. Long waits may indicate problems with the disk subsystem'
UNION ALL
SELECT 'PAGEIOLATCH_SH', 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Share mode. Long waits may indicate problems with the disk subsystem'
UNION ALL
SELECT 'PAGEIOLATCH_UP', 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Update mode. Long waits may indicate problems with the disk subsystem'
UNION ALL
SELECT 'PAGELATCH_DT', 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Destroy mode'
UNION ALL
SELECT 'PAGELATCH_EX', 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Exclusive mode'
UNION ALL
SELECT 'PAGELATCH_KP', 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Keep mode'
UNION ALL
SELECT 'PAGELATCH_SH', 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Shared mode'
UNION ALL
SELECT 'PAGELATCH_UP', 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Update mode'
UNION ALL
SELECT 'LOGBUFFER',
'DISK - Waiting for space in the log buffer to store a log record. Consistently high values may indicate that the log devices cannot keep up with the amount of log being generated by the server'
UNION ALL
SELECT 'ASYNC_IO_COMPLETION', 'DISK - Waiting for I/Os to finish'
UNION ALL
SELECT 'IO_COMPLETION', 'DISK - Waiting for I/O operations to complete. This wait type generally represents non-data page I/Os. Data page I/O completion waits appear as PAGEIOLATCH_* waits'
) b(wait_type, comment)
) b ON a.wait_type = b.wait_type
ORDER BY a.wait_time_ms DESC;
November 26, 2012 at 10:20 am
Elegant, reduced the logical reads needed to complete the query.
November 26, 2012 at 10:50 am
The temp tables are used to add the possible issues to the results. 🙂
Rudy
November 26, 2012 at 10:52 am
Thanks Greg for the updated code. As we all know there are more than one way to skin SQL server 😀
Rudy
Rudy
November 26, 2012 at 12:43 pm
Cadavre (11/26/2012)
Why do you need the temporary tables?
Good one Cadavre! Your derived tables got me thinking about it some more. I took out that big constant scan with all the UNIONs I used before and turned it into a CASE statement. That removed the need for a JOIN.
;WITH sdows AS (
SELECT
wait_type
,waiting_tasks_count
,wait_time_ms
,max_wait_time_ms
,signal_wait_time_ms
,'comment' = CASE
WHEN wait_type = 'SOS_SCHEDULER_YIELD' THEN 'CPU - Execute this script: SELECT scheduler_id, current_tasks_count, runnable_tasks_count FROM sys.dm_os_schedulers WHERE scheduler_id < 255 ;If runnable tasks count > zero, CPU issues if double digits for any length of time, extreme CPU concern'
WHEN wait_type = 'CXPACKET' THEN 'SETTINGS OR CODE - Wait stats shows more than 5% of your waits are on CXPackets, you may want to test lower (or non-zero) values of “max degree of parallelism”. Never set value great than # of CPUs'
WHEN wait_type = 'ASYNC_NETWORK_IO' THEN 'NETWORK - Occurs on network writes when the task is blocked behind the network'
WHEN wait_type = 'LCK_M_BU' THEN 'LOCK - Waiting to acquire a Bulk Update (BU) lock'
WHEN wait_type = 'LCK_M_IS' THEN 'LOCK - Waiting to acquire an Intent Shared (IS) lock'
WHEN wait_type = 'LCK_M_IU' THEN 'LOCK - Waiting to acquire an Intent Update (IU) lock '
WHEN wait_type = 'LCK_M_IX' THEN 'LOCK - Waiting to acquire an Intent Exclusive (IX) lock'
WHEN wait_type = 'LCK_M_RIn_NL' THEN 'LOCK - Waiting to acquire a NULL lock on the current key value and an Insert Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RIn_S' THEN 'LOCK - Waiting to acquire a shared lock on the current key value and an Insert Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RIn_U' THEN 'LOCK - Waiting to acquire an Update lock on the current key value, and an Insert Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RIn_X' THEN 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Insert Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RS_S' THEN 'LOCK - Waiting to acquire a Shared lock on the current key value, and a Shared Range lock between the current and previous'
WHEN wait_type = 'LCK_M_RS_U' THEN 'LOCK - Waiting to acquire an Update lock on the current key value, and an Update Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RX_S' THEN 'LOCK - Waiting to acquire a Shared lock on the current key value, and an Exclusive Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RX_U' THEN 'LOCK - Waiting to acquire an Update lock on the current key value, and an Exclusive range lock between the current and previous key'
WHEN wait_type = 'LCK_M_RX_X' THEN 'LOCK - Waiting to acquire an Exclusive lock on the current key value, and an Exclusive Range lock between the current and previous key'
WHEN wait_type = 'LCK_M_S' THEN 'LOCK - Waiting to acquire a Shared lock'
WHEN wait_type = 'LCK_M_SCH_M' THEN 'LOCK - Waiting to acquire a Schema Modify lock'
WHEN wait_type = 'LCK_M_SCH_S' THEN 'LOCK - Waiting to acquire a Schema Modify lock'
WHEN wait_type = 'LCK_M_SIU' THEN 'LOCK - Waiting to acquire a Shared With Intent Update lock'
WHEN wait_type = 'LCK_M_SIX' THEN 'LOCK - Waiting to acquire a Shared With Intent Exclusive lock'
WHEN wait_type = 'LCK_M_U' THEN 'LOCK - Waiting to acquire an Update lock'
WHEN wait_type = 'LCK_M_UIX' THEN 'LOCK - Waiting to acquire an Update With Intent Exclusive lock'
WHEN wait_type = 'LCK_M_X' THEN 'LOCK - Waiting to acquire an Exclusive lock'
WHEN wait_type = 'LATCH_DT' THEN 'LOCK - Waiting for a DT (destroy) latch. This does not include buffer latches or transaction mark latches'
WHEN wait_type = 'LATCH_EX' THEN 'LOCK - Waiting for an EX (exclusive) latch. This does not include buffer latches or transaction mark latches'
WHEN wait_type = 'LATCH_KP' THEN 'LOCK - Waiting for a KP (keep) latch. This does not include buffer latches or transaction mark latches'
WHEN wait_type = 'LATCH_SH' THEN 'LOCK - Waiting for an SH (share) latch. This does not include buffer latches or transaction mark latches'
WHEN wait_type = 'LATCH_UP' THEN 'LOCK - Waiting for an UP (update) latch. This does not include buffer latches or transaction mark latches'
WHEN wait_type = 'RESOURCE_SEMAPHORE' THEN 'MEMORY - Query memory request cannot be granted immediately due to other concurrent queries. High waits and wait times may indicate excessive number of concurrent queries, or excessive memory request amounts'
WHEN wait_type = 'RESOURCE_SEMAPHORE_MUTEX' THEN 'MEMORY - Query waits for its request for a thread reservation to be fulfilled. It also occurs when synchronizing query compile and memory grant requests'
WHEN wait_type = 'RESOURCE_SEMAPHORE_QUERY_COMPILE' THEN 'MEMORY - Number of concurrent query compilations reaches a throttling limit. High waits and wait times may indicate excessive compilations, recompiles, or uncachable plans'
WHEN wait_type = 'RESOURCE_SEMAPHORE_SMALL_QUERY' THEN 'MEMORY - Memory request by a small query cannot be granted immediately due to other concurrent queries. Wait time should not exceed more than a few seconds. High waits may indicate an excessive number of concurrent small queries while the main memory pool is blocked by waiting queries'
WHEN wait_type = 'WRITELOG' THEN 'MEMORY - Waiting for a log flush to complete. Common operations that cause log flushes are checkpoints and transaction commits'
WHEN wait_type = 'PAGEIOLATCH_DT' THEN 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Destroy mode. Long waits may indicate problems with the disk subsystem'
WHEN wait_type = 'PAGEIOLATCH_EX' THEN 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Exclusive mode. Long waits may indicate problems with the disk subsystem'
WHEN wait_type = 'PAGEIOLATCH_KP' THEN 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Keep mode. Long waits may indicate problems with the disk subsystem'
WHEN wait_type = 'PAGEIOLATCH_SH' THEN 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Share mode. Long waits may indicate problems with the disk subsystem'
WHEN wait_type = 'PAGEIOLATCH_UP' THEN 'DISK - Waiting on a latch for a buffer that is in an I/O request. The latch request is in Update mode. Long waits may indicate problems with the disk subsystem'
WHEN wait_type = 'PAGELATCH_DT' THEN 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Destroy mode'
WHEN wait_type = 'PAGELATCH_EX' THEN 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Exclusive mode'
WHEN wait_type = 'PAGELATCH_KP' THEN 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Keep mode'
WHEN wait_type = 'PAGELATCH_SH' THEN 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Shared mode'
WHEN wait_type = 'PAGELATCH_UP' THEN 'DISK - Waiting on a latch for a buffer that is not in an I/O request. The latch request is in Update mode'
WHEN wait_type = 'LOGBUFFER' THEN 'DISK - Waiting for space in the log buffer to store a log record. Consistently high values may indicate that the log devices cannot keep up with the amount of log being generated by the server'
WHEN wait_type = 'ASYNC_IO_COMPLETION' THEN 'DISK - Waiting for I/Os to finish'
WHEN wait_type = 'IO_COMPLETION' THEN 'DISK - Waiting for I/O operations to complete. This wait type generally represents non-data page I/Os. Data page I/O completion waits appear as PAGEIOLATCH_* waits'
ELSE NULL
END
FROM
sys.dm_os_wait_stats
WHERE
waiting_tasks_count <> 0
)
SELECT TOP 10
'OS WAIT STATS - WAIT TYPE' = wait_type
,'TASKS WAITING COUNT' = waiting_tasks_count
,'TIME WAITING (MS)' = wait_time_ms
,'MAX TIME WAITING (MS)' = max_wait_time_ms
,'SIGNAL TIME WAITING (MS)' = signal_wait_time_ms
,'POSSIBLE ISSUES' = comment
FROM
sdows
WHERE
comment IS NOT NULL
ORDER BY
wait_time_ms DESC
Rudy Panigas (11/26/2012)
As we all know there are more than one way to skin SQL server 😀
Ain't that the truth, Rudy.
November 27, 2012 at 8:28 am
I'm trying to understand the first two sets of results and where they come from in the code. You'll notice I get three result sets back, where do the first two "wait_type" come from and what is their significance?
Thanks!
Nick
November 27, 2012 at 8:47 am
nickm_GR (11/27/2012)
I'm trying to understand the first two sets of results and where they come from in the code. You'll notice I get three result sets back, where do the first two "wait_type" come from and what is their significance?Thanks!
Nick
Hi Nick,
You didn't include the results on your post so I can't help there. As for what this all means? The code was written to provide some direction not as a complete diagnostic tool. You still need to do your internet searches and/or contact MS support. But at least you will have the top 10 issues that you can show to others and/or MS support so that you can get some help.
i'm sure that's not what your looking for here but I can't help diagnose your system without a whole lot more information and time.
Thanks,
Rudy
Rudy
November 27, 2012 at 8:48 am
Many of us already know how to reset counters on the wait states however I saw a few people posting who are newer at this and want to know how they can determine wait states without it being cumulative since sql start. The command to reset the wait statistics is as follows:
DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR);
As with every other DBCC command, consider the ramifications before executing it and clear only if the benefits outweigh the drawbacks. If for example I had a customer that had always observed sluggishness between 1:30-2:30pm and they wanted to know what the system was waiting on only for that particular hour then clearing the wait stats might make sense. Unfortunately, clearing any of the dm counters means that you could potentially lose a long period of aggregated metrics that might show a more well rounded picture of system since it was built over a long period of time.
While most folks here already know this I am hoping this has helped at least one person
Tony
November 27, 2012 at 8:56 am
Excellent Tony. Thanks for the information.
Rudy
Rudy
November 27, 2012 at 12:51 pm
nickm_GR (11/27/2012)
I'm trying to understand the first two sets of results and where they come from in the code. You'll notice I get three result sets back, where do the first two "wait_type" come from and what is their significance?Thanks!
Nick
Hi Nick,
I got those too with the original version of the script. I am not familiar with cursors and perhaps it is some artifact of that or a typo. When I ran the code as re-written by either Greg Drake or Cadavre I don't get those extra results, just the nicely formatted table.
Viewing 15 posts - 16 through 30 (of 34 total)
You must be logged in to reply to this topic. Login to reply