1: 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.
How to use:
Open SQL SERVER Query Analyzer and enter the following statement:
SET STATISTICS profile on
SET STATISTICS IO on
SET STATISTICS time on
SQL statements
SET STATISTICS Profile OFF
SET STATISTICS IO OFF
SET STATISTICS Time OFF
Effect:
2: By adding statements manually, calculate the execution time to see how much time is spent executing the statement to determine how efficient the SQL statement is:
DECLARE @d datetime
Set @d=getdate ()
SQL statements
Select [Statement execution takes time (seconds)]=datediff (Ms,@d,getdate ())/1000.0
To view the SQL statement execution time