数据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;