Hi Friends,

This is based on a forum question and I see many are still confused with SQL Server Query Elapsed Time that you see under Messages tab in SSMS when the session is running with SET STATISTICS TIME ON.

SQL Server Elapsed Time represents the total time the query has taken, in milliseconds, to send the output to the console. And this includes Signal Wait Time, time spent on any Wait Types like PageIOLatch_*, IO_Completion or any other wait type including locking/blocking.

Let me explain with a quick example:

I run the following query:

and observe the output:

SQL_Server_Query_elapsed_Time_1

Elapsed time shows 0 ms – the query ran real quick!

Now, I will purposely introduce a blocking scenario for this query:

I execute this first in another query window (a new session):

and then back to the original session, I execute this, and the query waits:

After a few seconds, I rollback the transaction in the other query window:

Back to the first query window, let’s check the Messages tab:

SQL_Server_Query_elapsed_Time_2

This time, the query takes close to 3.5 seconds and it has spent most of its time waiting for the resource to be released which was locked by another transaction.