Compare the efficiency of different SQL statements

Source: Internet
Author: User

Open the query analyzer and select "show Execution Plan", "Show server trace", and "show Customer statistics" in the query menu.

In the editing window, enter the SQL statement to be compared, for example, different query methods:

Select *
From crm_fwd
Where RQ between '2017-06-01 'and '2017-06-02'
Select *
From crm_fwd
Where datediff (day, RQ, '2017-06-01 ') = 0
After the two SQL statements are run, the returned result sets are the same.

The execution plan pane shows that the cost of the first query is 6.72%, and that of the second is 93.28%. The second query has been used before. A beautiful colleague mm reminded me to realize this efficiency problem. We can also compare the index efficiency in this way.

If you need more detailed information, you can view the trace and Statistics pane. In the Execution Plan pane, place the cursor over the icon of each step, and the corresponding operation information is displayed.

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.