Question

When querying the sys.dm_exec_query_stats DMV, I am observing some interesting behaviour on the last_worker_time column.

Usually, it reports 0 for the specific stored procedure I am monitoring. However occasionally it will return a non-zero value, and when it does it seems to always be 976.

The MSDN documentation says the following about the last_worker_time column:

CPU time, reported in microseconds (but only accurate to milliseconds), that was consumed the last time the plan was executed.

However this doesn't explain the strange behaviour. Can anyone explain why the value 976 is so prolific?

The following simplified version of my DMV query produces this phenomenon:

select
    qs.last_worker_time
from
    sys.dm_exec_query_stats qs
    cross apply sys.dm_exec_sql_text(qs.plan_handle) st
where   
    db_name(st.dbid) = 'IntegrationManagement'
    and object_name(st.objectid, st.dbid) in ('GetFromOutQueue')

The SQL Server 2008 R2 instance is hosted on Windows Server 2008 R2 running on VMware.

Was it helpful?

Solution

You'd see this if the measurement was done with a timer that ticks 1024 times a second. Usually there's no tick between the start and end of the procedure, and the reported time is 0us. Sometimes there's one tick, and the reported time is 1/1024 second, rounded down to the nearest microsecond = 976 us.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top