有点意思

来源:互联网 发布:斯太尔wt数据俯仰角 编辑:程序博客网 时间:2024/06/09 17:30


定制自己的执行计划
explain plan for select * from emp a
join dept b
on a.deptno = b.deptno
where a.sal<3000;


delete plan_table
select * from plan_table;--只能执行一次
--从id=0开始,查找id=0左右的儿子
--prior 在哪边,优先显示哪边

select id "id",
lpad(' ',level) ||operation||' ' ||options "operation",
object_name "Name",
cardinality "Rows"
from plan_table a
start with id = 0
connect by prior id = parent_id;

当access_predicates,filter_predicates 任意一个不为空,id前面就有*,并显示出来
自己写:
select case when access_predicates is not null or filter_predicates is not null then '*'
else ' '
end || id "id",
lpad(' ', level) || operation || ' ' || options "operation",
object_name "Name",
cardinality "Rows",
access_predicates,
filter_predicates
from plan_table a
start with id = 0
connect by prior id = parent_id;
官方:

select case
when access_predicates is not null or filter_predicates is not null then
'*'
else
' '
end || id "Id",
lpad(' ', level) || operation || ' ' || options "Operation",
object_name "Name",
cardinality "Rows",
access_predicates,
filter_predicates
from plan_table a
start with id = 0
connect by prior id = parent_id;


0 0