有关Oracle 的执行计划说明,参考我的Blog:
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;
如:
-------------------------------------------------------------------------------------------------------
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929 DBA5群: 142216823
DBA6 群:158654907 聊天 群:40132017 聊天2群:69087192
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请