Database combination query

Source: Internet
Author: User
When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This leads to the topic of this blog. How to test the efficiency of SQL statements The following describes several ways to test the efficiency of SQL statements, most of which are searched online and tested one by one.

When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This leads to the topic of this blog. How to test the efficiency of SQL statements The following describes several ways to test the efficiency of SQL statements, most of which are searched online and tested one by one.

When writing SQL statements, we found that there are usually many implementation methods for the desired results. In the face of these implementation methods, how should we choose to be relatively optimal? This introduces the topic of this blog, how to test the efficiency of SQL statements

The following describes how to test the efficiency of Several SQL statements. Most of them are searched online and tested one by one. Finally, I made a new arrangement myself.

1. Test the SQL statement execution time method to obtain the time difference before and after the query
Declare @ begin_date datetimedeclare @ end_date datetimeselect @ begin_date = getdate () select top 100 * from dbo. VA_ExperimentProjectScore --
 <这里是你的语句...>
  
Select @ end_date = getdate () select datediff (MS, @ begin_date, @ end_date) as 'time/millisecond'
 
Result


2. The following method is comprehensive. The steps taken when each statement is executed are returned as a row set and displayed in the form of a hierarchy tree. The columns contained in the output are as follows:
Set statistics io onset statistics time ONgo --- select top 100 * from dbo. VA_ExperimentProjectScoregoSET STATISTICS profile offset statistics io offset statistics time OFF
Result


3. You can also set it in the tool.
Query-query option-advanced, there is a set statistics time hook, and then execute the SQL statement, read the message, there will be execution TIME


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.