When SQL statements are tuned, most of them look at the execution time of the statement, what do SQL Server's statistical results mean?
Let's take a look at the example
relatively simple statement:
Copy Code code as follows:
1 SET STATISTICS time on
2 Use [Pratice]
3 Go
4 SELECT * FROM [dbo]. [Orders]
Results:
Copy Code code as follows:
SQL Server profiling and compilation time:
CPU time = 0 milliseconds, elapsed time = 0 milliseconds.
SQL Server Execution Time:
CPU time = 0 milliseconds, elapsed time = 0 milliseconds.
SQL Server Execution Time:
CPU time = 0 milliseconds, elapsed time = 0 milliseconds.
SQL Server profiling and compilation time:
CPU time = 0 milliseconds, elapsed time = 0 milliseconds.
(121317 rows affected)
SQL Server Execution Time:
CPU time = 109 milliseconds, elapsed time = 2506 milliseconds.
The CPU time of the statement is divided into compile phase and execution stage. The optimizer first has to figure out how much CPU resources are used in each of these two phases.
Then, see if there is any optimization to reduce CPU usage
The CPU time above refers to the time that the statement is executed
Elapsed time refers to the total elapsed time when data is read from disk and processed
Compile Phase:
SQL Server profiling and compilation time:
implementation Phase:
SQL Server Execution Time: