ITPub博客

首页 > 大数据 > 数据挖掘 > 百事3主管7288481ORACLE SQL执行计划

百事3主管7288481ORACLE SQL执行计划

原创 数据挖掘 作者:百事主管7288481 时间:2020-12-21 23:26:02 0 删除 编辑

--explain查看SQL执行计划

EXPLAIN PLAN FOR select count(*) from steven.AWEN_OGG_TEST;

select * from table(dbms_xplan.display());

--查看AWR和CURSOR中的执行计划

select * from table(dbms_xplan.display_awr('&sqlid'));

select * from table(dbms_xplan.display_cursor('&sqlid'));

--查看内存中的执行计划

select '| Operation |Object Name | Rows | Bytes| Cost |'

as "Explain Plan in library cache:" from dual

union all

select rpad('| '||substr(lpad(' ',1*(depth-1))||operation||

decode(options, null,'',' '||options), 1, 35), 36, ' ')||'|'||

rpad(decode(id, 0, '----------------------------',

substr(decode(substr(object_name, 1, 7), 'SYS_LE_', null, object_name)

||' ',1, 30)), 31, ' ')||'|'|| lpad(decode(cardinality,null,' ',

decode(sign(cardinality-1000), -1, cardinality||' ',

decode(sign(cardinality-1000000), -1, trunc(cardinality/1000)||'K',

decode(sign(cardinality-1000000000), -1, trunc(cardinality/1000000)||'M',

trunc(cardinality/1000000000)||'G')))), 7, ' ') || '|' ||

lpad(decode(bytes,null,' ',

decode(sign(bytes-1024), -1, bytes||' ',

decode(sign(bytes-1048576), -1, trunc(bytes/1024)||'K',

decode(sign(bytes-1073741824), -1, trunc(bytes/1048576)||'M',

trunc(bytes/1073741824)||'G')))), 6, ' ') || '|' ||

lpad(decode(cost,null,' ', decode(sign(cost-10000000), -1, cost||' ',

decode(sign(cost-1000000000), -1, trunc(cost/1000000)||'M',

trunc(cost/1000000000)||'G'))), 8, ' ') || '|' as "Explain plan"

from v$sql_plan sp

where sp.hash_value=&hash_value or sp.sql_id='&sqlid';

--查看历史执行计划

select distinct SQL_ID,PLAN_HASH_VALUE,to_char(TIMESTAMP,'yyyymmdd hh24:mi:ss') TIMESTAMP

from dba_hist_sql_plan

where SQL_ID='&sqlid' order by TIMESTAMP;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69989787/viewspace-2744192/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论
百事3主管7288481

注册时间:2020-12-01

  • 博文量
    1
  • 访问量
    145