Ai
1 Star 1 Fork 0

冯际成/Oracle_SQL_Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
plan_memory.sql 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
Abdul mohammed 提交于 2016-02-06 08:58 +08:00 . Fri Feb 5 18:58:16 CST 2016
--------------------------------------------------------------------------------
--
-- File name: xm.sql (eXplain from Memory)
--
-- Purpose: Explain a SQL statements execution plan directly from library cache
--
-- Author: Tanel Poder
-- Copyright: (c) http://www.tanelpoder.com
--
-- Usage: Identify the hash value and and child cursor number for the query
-- you want to explain (either from v$session.sql_hash_value or by
-- searching through v$sql.sql_text
--
-- Then run:
-- @xm <hash_value> <child_number>
--
-- For example:
-- @xm 593239587 0 -- this would show plan for child 0 of cursor
-- -- with hash value 593239587
--
-- @xm 593239587 % -- this would show all child cursors for the SQL
--
--------------------------------------------------------------------------------
column xms_child_number heading Ch|ld format 9 print
column xms_id heading Op|ID format 999
column xms_id2 heading Op|ID format a6
column xms_pred heading Pr|ed format a2
column xms_optimizer heading Optimizer|Mode format a10
column xms_plan_step heading Operation for a55
column xms_object_name heading Objcect|Name for a30
column xms_opt_cost heading Optimizer|Cost for 9999999
column xms_opt_card heading "Optim rows|from step" for 999999999
column xms_opt_bytes heading "Optim bytes|from step" for 999999999
column xms_predicate_info heading "Predicate Information (identified by operation id):" format a100 word_wrap
break on xms_child_number skip 1
select
child_number xms_child_number,
case when access_predicates is not null then 'A' else ' ' end ||
case when filter_predicates is not null then 'F' else ' ' end xms_pred,
id xms_id,
lpad(' ',depth*1,' ')||operation || ' ' || options xms_plan_step,
object_name xms_object_name,
-- search_columns,
cost xms_opt_cost,
cardinality xms_opt_card,
bytes xms_opt_bytes,
optimizer xms_optimizer
-- other_tag,
-- other,
-- distribution,
-- access_predicates,
-- filter_predicates
from
v$sql_plan
where
hash_value in (&1)
and to_char(child_number) like '&2' -- to_char is just used for convenient filtering using % for all children
/
select * from (
select
child_number xms_child_number,
lpad(id, 5, ' ') xms_id2,
' - access('|| substr(access_predicates,1,3989) || ')' xms_predicate_info
from
v$sql_plan
where
hash_value in (&1)
and to_char(child_number) like '&2'
and access_predicates is not null
union all
select
child_number,
lpad(id, 5, ' ') xms_id2,
' - filter('|| substr(filter_predicates,1,3989) || ')' xms_predicate_info
from
v$sql_plan
where
hash_value in (&1)
and to_char(child_number) like '&2'
and filter_predicates is not null
)
order by xms_child_number, xms_id2
/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sapall/Oracle_SQL_Scripts.git
git@gitee.com:sapall/Oracle_SQL_Scripts.git
sapall
Oracle_SQL_Scripts
Oracle_SQL_Scripts
master

搜索帮助