Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8979

Query Execution time - Elapsed time v Actual time taken

$
0
0

Hi All,

I have this scenario where I am querying a single table with the following results. It is a very heavy query in that there are multiple aggregate functions and multiple unions on it. Even if the query is written poorly (i doubt it is) why would the actual time taken to execute the query be much more than the statistics provided through the following commands?

SET STATISTICS IO ON;
SET STATISTICS TIME ON;

Attached are the stats provided for the relevant query in question.

Table '123456789_TEMP_DATA'. Scan count 178, logical reads 582048, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
   CPU time = 936 ms,  elapsed time = 967 ms.
2014-01-06 17:36:41.383

Now, although the CPU Time/Elapsed time shows that it takes less than a second, it actually takes more than 15 seconds to fetch the results. (This is the actual time that you get on the bottom bar of the Query pane as well.)

What is the reason? Why is it that there is such a big discrepancy between the numbers? How can I improve this situation?

Thanks!


Viewing all articles
Browse latest Browse all 8979

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>