用sql 基线 替换执行计划

数据oracle

select * from DBA_SQL_PROFILES;

SYS_SQLPROF_01945ecb1bbc0001

begin

dbms_sqltune.drop_sql_profile(name => 'SYS_SQLPROF_01945ecb1bbc0001');

end;

select * from v$sqlarea where sql_text like '%ShadowBaseline%'

SELECT /* outlinetest223 */ /*+ index(A0 KX_SHADOWCACHECOMPOSITE01) USE_NL(A0 A1 ) INDEX(A1 KX_SHADOWBASELINECOMPOSITE01) */ 'wt.shadow.ShadowBaseline',

A1.Checksum,

A1.ObjectRef,

A1.ObjectRole,

A1.ShadowClass,

A1.ShadowContext,

A1.ShadowTarget,

A1.UpdateCount,

TO_CHAR(A1.createStampA2, 'dd mm yyyy hh24:mi:ss'),

A1.markForDeleteA2,

TO_CHAR(A1.modifyStampA2, 'dd mm yyyy hh24:mi:ss'),

A1.idA2A2,

A1.updateCountA2,

TO_CHAR(A1.updateStampA2, 'dd mm yyyy hh24:mi:ss'),

A0.shadowCacheida2a2

FROM (SELECT INNER0.idA2A2 shadowCacheida2a2,

INNER0.CacheClass shadowclassname,

INNER0.ObjectID shadowObjectRef,

INNER0.ShadowContextId shadowContextId

FROM ShadowCache INNER0) A0,

ShadowBaseline A1

WHERE ((A1.ShadowClass = A0.shadowclassname) AND

(A1.ShadowContext = A0.shadowContextId) AND

(A1.ObjectRef = A0.shadowObjectRef))

AND (A1.markForDeleteA2 = 0)

select sql_text,sql_id,hash_value,child_number,plan_hash_value,to_char(LAST_ACTIVE_TIME,'hh24:mi:ss') time

from v$sql a where sql_text like '%outlinetest223%' and sql_id='5kcr4yj9swmb6'

select sql_text,sql_id,hash_value,child_number,plan_hash_value,to_char(LAST_ACTIVE_TIME,'hh24:mi:ss') time

from v$sql a where sql_text like '%outlinetest221%' and sql_id='4yw39bfnn09ac'

select * from table(dbms_xplan.display_cursor('5kcr4yj9swmb6','',''));

增加基线实验方法

DECLARE

k1 pls_integer;

begin

k1 := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE (

sql_id=>'5kcr4yj9swmb6',

plan_hash_value=>1563245533

);

end;

DECLARE

k1 pls_integer;

begin

k1 := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE (

sql_id=>'1291knkqd5bsd',

plan_hash_value=>1563245533

);

end;

SELECT /* outlinetest221 */ 'wt.shadow.ShadowBaseline',

A1.Checksum,

A1.ObjectRef,

A1.ObjectRole,

A1.ShadowClass,

A1.ShadowContext,

A1.ShadowTarget,

A1.UpdateCount,

TO_CHAR(A1.createStampA2, 'dd mm yyyy hh24:mi:ss'),

A1.markForDeleteA2,

TO_CHAR(A1.modifyStampA2, 'dd mm yyyy hh24:mi:ss'),

A1.idA2A2,

A1.updateCountA2,

TO_CHAR(A1.updateStampA2, 'dd mm yyyy hh24:mi:ss'),

A0.shadowCacheida2a2

FROM (SELECT INNER0.idA2A2 shadowCacheida2a2,

INNER0.CacheClass shadowclassname,

INNER0.ObjectID shadowObjectRef,

INNER0.ShadowContextId shadowContextId

FROM ShadowCache INNER0) A0,

ShadowBaseline A1

WHERE ((A1.ShadowClass = A0.shadowclassname) AND

(A1.ShadowContext = A0.shadowContextId) AND

(A1.ObjectRef = A0.shadowObjectRef))

AND (A1.markForDeleteA2 = 0)

select t1.*,dbms_lob.substr(sql_text,60,1) sql_text,ACCEPTED from dba_sql_plan_baselines t1;

查询具体解释计划的的具体内容

select * from table(dbms_xplan.display_sql_plan_baseline(sql_handle=>'SYS_SQL_547c80668cfa3cc4',plan_name=>'SQL_PLAN_58z40cu6gng641d5ff949'));

SQL_PLAN_dvmhk3njraxsy1d5ff949

删除 SQL_PLAN_58z40cu6gng64ad9e551b

SYS_SQL_ddce121d2375771e

SQL_PLAN_dvmhk3njraxsy4f42a20a

将其他计划加入同一个sql_handle

DECLARE

k1 pls_integer;

begin

k1 := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE (

sql_id=>'4yw39bfnn09ac',

plan_hash_value=>4050511003,sql_handle=>'SYS_SQL_547c80668cfa3cc4'

);

end;

尝试创建其他的基线

DECLARE

k1 pls_integer;

begin

k1 := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE (

sql_id=>'533vzcjak17w4',

plan_hash_value=>4050511003

);

end;

删除废的方法

DECLARE

k1 pls_integer;

begin

k1 := DBMS_SPM.drop_sql_plan_baseline ( sql_handle=>'SYS_SQL_c734f5e1c718dd5f',plan_name=>'SQL_PLAN_cfd7pw73jjrazad9e551b');

end;

相关推荐
矛取矛求14 分钟前
C++ 标准库参考手册深度解析
java·开发语言·c++
cijiancao16 分钟前
23 种设计模式中的解释器模式
java·设计模式·解释器模式
南七行者18 分钟前
对模板方法模式的理解
java·设计模式·模板方法
٩( 'ω' )و26023 分钟前
stl_list的模拟实现
开发语言·c++·list
麻芝汤圆40 分钟前
MapReduce 的广泛应用:从数据处理到智能决策
java·开发语言·前端·hadoop·后端·servlet·mapreduce
努力的搬砖人.41 分钟前
java如何实现一个秒杀系统(原理)
java·经验分享·后端·面试
珊瑚里的鱼1 小时前
第五讲(下)| string类的模拟实现
开发语言·c++·笔记·程序人生·算法·visualstudio·visual studio
哈哈哈哈哈哈哈哈哈...........1 小时前
【java】在 Java 中,获取一个类的`Class`对象有多种方式
java·开发语言·python
@小白向前冲1 小时前
python 重要易忘 语言基础
开发语言·python
fallwind_of_july1 小时前
java项目分享-分布式电商项目附软件链接
java·redis·分布式·mongodb·elasticsearch·微服务·rabbitmq