Oracle getting started Tutorial: leading vs ordered hint

Source: Internet
Author: User

Leading hint indicates that Oracle uses the table specified in leading as the driving table,
For example, the normal access plan is as follows:
SCOTT@www.bkjia.com> select e. ename, hiredate, B. comm
2 from emp e, bonus B
3 where e. ename = B. ename;
Execution Plan
----------------------------------------------------------
Plan hash value: 1125985041
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
----------------------------------------------------------------------------
| 0 | select statement | 1 | 34 | 6 (17) | 00:00:01 |
| * 1 | hash join | 1 | 34 | 6 (17) | 00:00:01 |
| 2 | table access full | BONUS | 1 | 20 | 2 (0) | 00:00:01 |
| 3 | table access full | EMP | 14 | 196 | 3 (0) | 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id ):
---------------------------------------------------
1-access ("E". "ENAME" = "B". "ENAME ")


In the leading prompt, specify the emp table as the driver table.
SCOTT@www.bkjia.com> select/* + leading (e B) */e. ename, hiredate, B. comm

2 from emp e, bonus B
3 where e. ename = B. ename;
Execution Plan
----------------------------------------------------------
Plan hash value: 1842254584
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
----------------------------------------------------------------------------
| 0 | select statement | 1 | 34 | 6 (17) | 00:00:01 |
| * 1 | hash join | 1 | 34 | 6 (17) | 00:00:01 |
| 2 | table access full | EMP | 14 | 196 | 3 (0) | 00:00:01 |
| 3 | table access full | BONUS | 1 | 20 | 2 (0) | 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id ):
---------------------------------------------------
1-access ("E". "ENAME" = "B". "ENAME ")
If emp is used as the driving table in the result execution plan!
1. If both ordered hint and leading prompt are used, the leading hint is invalid.
SCOTT@www.bkjia.com> select/* + leading (B e) ordered */e. ename, hiredate, B. comm

2 from emp e, bonus B
3 where e. ename = B. ename;
Execution Plan
----------------------------------------------------------
Plan hash value: 1842254584
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
----------------------------------------------------------------------------
| 0 | select statement | 1 | 34 | 6 (17) | 00:00:01 |
| * 1 | hash join | 1 | 34 | 6 (17) | 00:00:01 |
| 2 | table access full | EMP | 14 | 196 | 3 (0) | 00:00:01 |
| 3 | table access full | BONUS | 1 | 20 | 2 (0) | 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id ):
---------------------------------------------------
1-access ("E". "ENAME" = "B". "ENAME ")
2. If two conflicting leading hints are used, oracle cbo ignores all leading prompts!
SCOTT@www.bkjia.com> select/* + leading (B e) leading (e B) */e. ename, hiredate, B. comm

2 from emp e, bonus B
3 where e. ename = B. ename;
Execution Plan
----------------------------------------------------------
Plan hash value: 1125985041
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
----------------------------------------------------------------------------
| 0 | select statement | 1 | 34 | 6 (17) | 00:00:01 |
| * 1 | hash join | 1 | 34 | 6 (17) | 00:00:01 |
| 2 | table access full | BONUS | 1 | 20 | 2 (0) | 00:00:01 |
| 3 | table access full | EMP | 14 | 196 | 3 (0) | 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id ):
---------------------------------------------------
1-access ("E". "ENAME" = "B". "ENAME ")

  • 1
  • 2
  • Next Page

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.