用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;

相关推荐
宏夏c1 分钟前
【Vue】let、const、var的区别、适用场景
开发语言·javascript·ecmascript
zzyh1234562 分钟前
spring cloud 负载均衡策略
java·spring cloud·负载均衡
涔溪2 分钟前
JS二叉树是什么?二叉树的特性
java·javascript·数据结构
贩卖纯净水.3 分钟前
JS后盾人--再一次的走进JS?
开发语言·javascript·ecmascript
黄金小码农17 分钟前
二级C语言 2025/1/14
c语言·开发语言
zzyh12345624 分钟前
springcloud负载均衡原理
java·spring cloud·负载均衡
东北赵四33 分钟前
JVM之垃圾回收器G1概述的详细解析
java·开发语言·jvm
DX_水位流量监测1 小时前
雷达流量监测系统:精准监控水流,确保水资源安全
大数据·开发语言·网络·人工智能·安全·信息可视化
2403_875180951 小时前
一键掌握多平台短视频矩阵营销/源码部署
java·前端·数据结构·线性代数·矩阵·php
向阳12181 小时前
doris:手动分区
java·服务器·windows·doris