Oracle searches for real execution plans from the cache

Source: Internet
Author: User

For more information about Oracle execution plans, see Oracle Explain Plan.

1. view the SID of the current session
SYS @ anqing1 (rac1)> select userenv ('sid ') from dual;
USERENV ('sid ')
SYS @ anqing1 (rac1)> select sid from v $ mystat where rownum = 1;

2. view the Explain Plan in the cache
1) locate the HASH_VALUE and ADDRESS of the corresponding SQL statement from v $ SQL according to the SID.
/* Formatted on 17:38:20 (QP5 v5.163.1008.3004 )*/
SELECT a. SQL _text, a. address, a. hash_value
FROM v $ SQL a, v $ session B
WHERE a. hash_value = B. SQL _hash_value AND B. sid = & sid;

2) Find the actual execution plan from v $ SQL _plan Based on the hash_value and address values.
/* Formatted on 17:39:22 (QP5 v5.163.1008.3004 )*/
Set line 200;
COL protocol FORMAT a100;
Select lpad (latency, LENGTH (latency) + LEVEL * 2, '') latency, cost
FROM (SELECT object_name | ':' | operation | ''| options AS operation,
FROM v $ SQL _plan
WHERE hash_value = '& hash_value' AND address = '& address ')
Start with id = 0
Connect by prior id = parent_id;
For example:

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: 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.