The performance of the SQL statement is measured in MSSQL server by looking at the time it took to execute the SQL statement.
By setting STATISTICS We can view the system situation when executing SQL. The options are Profile,io, time. Introduced as follows:
SET STATISTICS profile on: Displays the time, in milliseconds, that is required to parse, compile, and execute the query.
SET STATISTICS IO on: Reports information about the number of scans per table referenced in the statement, the number of logical reads (pages accessed in the cache), and the number of physical reads (the number of times the disk was accessed).
Set STATISTICS time on: Displays the result set after each query execution, representing the configuration file that the query executes.
Method one manual calculation
The time before execution is recorded, then the time after the execution of the SQL is recorded, and then the subtraction
Declare @d datetime Set @d = getdate ()/* your SQL script starts */* your SQL script ends */Select [ statement execution takes time (milliseconds)]=DateDiff(MS,@d, GetDate())
This method does not feel accurate enough, compared with the second method, the time display is longer, may be the operation time of the relevant function caused it
Method two using SQL to turn on the self-brought statistics
The steps taken when executing each statement are returned as rowsets, shown in the form of a hierarchy tree
SET STATISTICSProfile on SET STATISTICSIo on SET STATISTICSTime on GO/*--Your SQL script starts*/
/*your SQL script is over*/GO SET STATISTICSProfileOFF SET STATISTICSIoOFF SET STATISTICSTimeOFF
The 2nd method effects such as,
Method three with SQL Server comes with the tool
Location: Tools Options Query Execution Advanced
Effect
Original: http://www.cnblogs.com/wangguowen27/p/SqlServer_Select_wgw.html
Related:
http://blog.csdn.net/hj850126/article/details/7161028
Http://www.cnblogs.com/qanholas/archive/2011/05/06/2038543.html
SQL Server to view the execution time of the statement