Home > Database > Mysql Tutorial > body text

Oracle 从缓存里面查找真实的执行计划

WBOY
Release: 2016-06-07 17:05:40
Original
1095 people have browsed it

有关Oracle 的执行计划说明,参考:Oracle Explain Plan

有关Oracle 的执行计划说明,参考:Oracle Explain Plan 见

一.  查看当前session 的SID
SYS@anqing1(rac1)> SELECT USERENV('SID') FROM DUAL;
USERENV('SID')
--------------
137
SYS@anqing1(rac1)> SELECT SID FROM V$MYSTAT WHERE ROWNUM =1;
SID
----------
137

二.  查看缓存中的Explain Plan
1)根据SID,从v$sql中找到相应SQL的HASH_VALUE和ADDRESS
/* Formatted on 2011/6/20 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)根据hash_value和address的值,从v$sql_plan中找到真实的执行计划
/* Formatted on 2011/6/20 17:39:22 (QP5 v5.163.1008.3004) */
SET LINE 200;
COL oper FORMAT a100;
SELECT LPAD (oper, LENGTH (oper) + LEVEL * 2, ' ') oper, cost
FROM (SELECT object_name || ':' || operation || ' ' || options AS oper,
cost,
id,
parent_id
FROM v$sql_plan
WHERE hash_value = '&hash_value' AND address = '&address')
START WITH id = 0
CONNECT BY PRIOR id = parent_id;
如:

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!