To test SQL performance:
One, by setting statistics to view the system situation when executing SQL. Options: Profile, O, time.
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.
Examples are as follows:
SET STATISTICS profile on
SET STATISTICS IO on
SET STATISTICS time on
GO
–sql Script Start
SELECT [TestCase] from [Testcaseselect]
–sql Script End
GO
SET STATISTICS Profile OFF
SET STATISTICS IO OFF
SET STATISTICS Time OFF
Alternatively, you can determine the efficiency of the SQL statement by manually adding the statement to calculate the execution time to see how long it takes to execute the statement:
DECLARE @d datetime
Set @d=getdate ()
–sql Script Start
SELECT [TestCase] from [Testcaseselect]
–sql Script End
Select [Statement execution takes time (milliseconds)]=datediff (Ms,@d,getdate ())
Second, the "include Actual execution plan" and "include client statistics" under the "Query" button of SQL 2008.
Note: Large tables with small tables associated with the search, involving nested queries, first query the small table, and then union large tables.
SQL execution efficiency and performance test methods (SQL Server)