首页 > 数据库技术 > 详细

执行计划固定(sql profile)

时间:2019-11-19 16:03:00      阅读:99      评论:0      收藏:0      [点我收藏+]

查看sql是否被执行计划绑定
select sql_profile,sql_plan_baseline from v$sql where sql_id=‘xx‘

declare
v_hints sys.sqlprof_attr;
cl_sql_text clob;
wrong_sql_id varchar2(50):=‘259au46k8mbku‘;--错误的sql_id
right_sql_id varchar2(50):=‘259au46k8mbku‘;--正确的sql_id
right_child_num number:=4;
right_PLAN_HASH_VALUE number :=2573941063;--正确执行计划的hash plan 
begin
select extractvalue(VALUE(d), ‘/hint‘) bulk collect
into v_hints
from xmltable(‘/*/outline_data/hint‘ passing
(select xmltype(other_xml) as xmlval
from dba_hist_sql_plan
where sql_id = right_sql_id
and PLAN_HASH_VALUE=right_PLAN_HASH_VALUE
and other_xml is not null)) d;
select sql_fulltext
into cl_sql_text
from v$sql
where sql_id = wrong_sql_id
and Rownum = 1;
dbms_sqltune.import_sql_profile(cl_sql_text,
v_hints,
‘P_‘||wrong_sql_id,
force_match => true,
replace => true);
end;
/

执行计划固定(sql profile)

原文:https://www.cnblogs.com/muzisanshi/p/11889727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!