我需要从Oracle中的查询计划自动获取hash_plan_value。我知道,当我为“我的查询”执行解释计划时,我可以看到它,然后SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY())向我展示了整个计划。
但我的观点是,我没有在PLAN_TABLE的列中找到它。例如,我可以使用选择成本、基数、PLAN_TABLE字节来获得成本、基数和字节,是否也有获得PLAN_HASH_VALUE的方法?我是说,既然它被展示了,它就在那里,但我不知道它在哪里。希望我说得够清楚..。
发布于 2015-09-10 04:45:15
计划散列存储在OTHER_XML列中的PLAN_TABLE行中。
样例计划
explain plan set statement_id = 'TEST3' for select * from dual connect by level <= 10;
select * from table(dbms_xplan.display);
Plan hash value: 2874664061
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
|* 1 | CONNECT BY WITHOUT FILTERING| | | | | |
| 2 | TABLE ACCESS FULL | DUAL | 1 | 2 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(LEVEL<=10)查询提取PLAN_HASH
select extractValue(xmltype(other_xml), '/other_xml/info[@type="plan_hash"]') plan_hash
from plan_table
where other_xml is not null
and statement_id = 'TEST3';
PLAN_HASH
---------
2874664061https://stackoverflow.com/questions/32485040
复制相似问题