Oracle uses stored outline to solidify the execution plan -- CURSOR_SHARING

Source: Internet
Author: User

The Oracle execution plan storage outline corresponds to the SQL statement one by one. Therefore, if we change the predicate condition in the SQL statement, the storage outline will be ineffective or we need to create a new storage outline to consolidate the execution plan. To avoid this, we can use variables to replace text information.

Without binding variables:

SQL> show user
The USER is EASY1"
SQL> select * from tab;

TNAME TABTYPE CLUSTERID
-----------------------------------------------
T1 TABLE

SQL> select ol_name, creator from outln. ol $;

Unselected row

SQL> create outline outline1 on select count (*) from t1 where object_id <100;

The outline has been created.

SQL> set autotrace on explain
SQL> alter session set use_stored_outlines = true;

The session has been changed.

SQL> select count (*) from t1 where object_id <100;

COUNT (*)
----------
98


Execution Plan
----------------------------------------------------------
Plan hash value: 3900446664

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
--------------------------------------------------------------------------
| 0 | select statement | 1 | 13 | 3 (0) | 00:00:01 |
| 1 | sort aggregate | 1 | 13 |
| * 2 | index range scan | I1 | 4411 | 57343 | 3 (0) | 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id ):
---------------------------------------------------

2-access ("OBJECT_ID" <100)

Note
-----
-Outline "OUTLINE1" used for this statement

SQL> select count (*) from t1 where object_id <200;

COUNT (*)
----------
192


Execution Plan
----------------------------------------------------------
Plan hash value: 3900446664

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
--------------------------------------------------------------------------
| 0 | select statement | 1 | 13 | 2 (0) | 00:00:01 |
| 1 | sort aggregate | 1 | 13 |
| * 2 | index range scan | I1 | 192 | 2496 | 2 (0) | 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id ):
---------------------------------------------------

2-access ("OBJECT_ID" <200)

Note
-----
-Dynamic sampling used for this statement (level = 2)

  • 1
  • 2
  • 3
  • 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.