Query Statement Execution order

Source: Internet
Author: User

The order in which the query statements are executed depends on the following clauses:

1.from clauses: The order of execution is from backward, right to left

A table with a small amount of data is kept as far back as possible

2.where clauses: The execution order is bottom-up, right-to-left

Writes the criteria that can filter out the maximum number of records to the right of the WHERE clause

3.group by--The execution sequence is grouped from left to right

It is best to use where before group by to filter out unwanted records before group by

4.HAVING clause: Consuming resources

Try to avoid using it, having the result set filtered after all records have been retrieved, ordered, etc.

5.select clause: Use less * and take field names as much as possible.

During the parsing process, Oracle converts the * number to all column names by querying the data dictionary, which consumes time

6.order BY clause: Order of execution from left to right, consuming resources

Query Statement Execution order

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.