SQL execution efficiency and performance test methods (SQL Server)

Source: Internet
Author: User
Tags sql 2008

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.