Several Methods for SQL optimization and SQL Optimization

Source: Internet
Author: User

Several Methods for SQL optimization and SQL Optimization

1. Create views of commonly used data to minimize query methods such as group by, order by, and update;

2. Establish a reasonable index;

3. Select and project first, and then connect (projection is to select the required columns from the given table; selection is to select the required rows );

4. replace in with exists. in connects the External table to the internal table as hash, while exists performs loop on the External table. Each loop then queries the internal table, that is, if the subquery table is large, the exists clause is used. If the subquery table is small, the in clause is used. The External table is located before the where clause, and the subquery is followed by the where clause. in addition, no matter which table is large, not exists is faster than not in;

5. use hints to specify the oracle optimizer. The optimizer selects an execution scheme based on these hints (Oracle Hints is a mechanism, it is used to tell the optimizer to generate an execution plan as we tell it ).

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.