脚本内容
-- 给特定SQL绑上改写后的特定执行计划,需要事先查询得到对应的sql_id 和 plan_hash_value, COE_profile.sql的极简版
declare
v_hint SYS.SQLPROF_ATTR;
v_sql_text clob;
begin
select sql_fulltext into v_sql_text from v$sql where sql_id = '&bad_sqlid' and rownum=1;
select extractvalue(value(d), '/hint') as outline_hints bulk collect
into v_hint
from xmltable('/*/outline_data/hint' passing
(select xmltype(other_xml) as xmlval
from v$sql_plan
where sql_id = '&good_sqlid'
and other_xml is not null)) d;
dbms_sqltune.import_sql_profile(
v_sql_text,
v_hint,
'sql_profile_&bad_sqlid',
force_match=>true,replace=>true
);
end;
/
评论
贡献排行榜