I am building application in C#
which is parsing Actual Execution Plan. I need basic stats like Row count
, CPU time
, Page Reads
etc. All above stats I found in XML
of Actual Execution Plan. I can not find time duration of executed query. Do you know If it is possible to retrieve it ?
1 Answer
It should be the node QueryTimeStats
there will be a section for CPUTime
and ElapsedTime
. The time is in milleseconds.
CPUTime
may be longer than ElapsedTime
due to the query going parallel across multiple CPU cores, this is expected behavior.
ElapsedTime
may be longer than CPUTime
when a query is blocked, or waiting on non-CPU resources to complete. Things like reading pages from disk into memory, or writing to the transaction log, etc.
You may want to try to parse the WaitStats
section of the XML for additional details on this, but be aware that it does not include all waits. For example, lock waits and CXCONSUMER
are not included in the collection.