Oracle technology: How to use the ordered hint to change the SQL execution plan

Source: Internet
Author: User
Tags data structures execution

Ordered prompts to force Oracle to join tables in the order in which they appear in the FROM clause.

By ordered hints, you can avoid table connection evaluations during the CBO SQL parsing process, thus avoiding Oracle generating incorrect execution plans or forcing Oracle to execute in the way we specify.

In many cases, when we have a clear understanding of data structures and distributions, we can improve SQL performance with ordered hints.

Let's illustrate the role of ordered hints with the following examples.

1. SQL execution plan without hints

We can trace this SQL parsing through the 10053 event:

Looking at the trace file you can see that Oracle needs to be 3! (6) Evaluation of the Order of the secondary table connection:

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

2. When we use the ordered prompt

The execution plan for SQL is as follows (the order of the tables after the FROM clause is adjusted):

Look at the trace trace file for 10053 again:

Oracle only needs to be connected according to the order in which the table appears in the FROM clause to parse or execute according to our intent.

This is the basic role of the ordered hint, and this example is just a demonstration that the latter's implementation plan makes the cost surge, and we certainly do not want to see such growth in practical applications.

Author: 51cto Blog Oracle Little Bastard

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.