During SQL statement optimization, most of them will view the statement execution time. What is the statistical result displayed by sqlserver?
The following is an example.
Simple statement:
1 Set StatisticsTimeOn2 Use [Pratice]3 Go4 Select * From [DBO].[Orders]
Result:
1 SQL Server Analysis and Compilation Time: 2 CPU time = 0 Millisecond, occupied time = 0 Milliseconds. 3 4 SQL Server execution time: 5 CPU time = 0 Millisecond, occupied time= 0 Milliseconds. 6 7 SQL Server execution time: 8 CPU time = 0 Millisecond, occupied time = 0 Milliseconds. 9 SQL Server Analysis and Compilation Time: 10 CPU time= 0 Millisecond, occupied time = 0 Milliseconds. 11 12 ( 121317 Rows affected) 13 14 SQL Server execution time: 15 CPU time = 109 Millisecond, occupied time= 2506 Milliseconds.
CPU time of the statementCompilation phaseAndExecution phase. The optimizer should first figure out how many CPU resources are used in each phase.
Then, let's see if there is any possibility of optimizing and reducing CPU usage.
The aboveCPU timeThe time when the statement is executed.
WhileTime usedIndicates the total time used to read data from a disk and then process the data.
Compilation phase:
SQL Server Analysis and Compilation Time:
Execution phase:
SQL Server execution time: