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:
Copy codeThe Code is as follows: 1 SET STATISTICS TIME ON
2 USE [pratice]
3 GO
4 SELECT * FROM [dbo]. [Orders]
Result:Copy codeThe Code is as follows: SQL Server Analysis and Compilation Time:
CPU time = 0 ms, occupied time = 0 ms.
SQL Server execution time:
CPU time = 0 ms, occupied time = 0 ms.
SQL Server execution time:
CPU time = 0 ms, occupied time = 0 ms.
SQL Server Analysis and Compilation Time:
CPU time = 0 ms, occupied time = 0 ms.
(Row 3 is affected)
SQL Server execution time:
CPU time = 109 milliseconds, occupied time = 2506 milliseconds.
The CPU time of a statement is divided into the compilation and execution phases. 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 preceding CPU time indicates the statement execution time.
The Occupied time refers to the total time used to read data from the disk and then process the data.
Compilation phase:
SQL Server Analysis and Compilation Time:
Execution phase:
SQL Server execution time: