Posts

Showing posts from July, 2021

SQL Plan Transfer

A small example to demonstrate this  plan_hash_value= 4160939255 sqlid = 0zwsk3sanq3mp SQL> set serveroutput on SQL> declare      ret binary_integer;      l_sql_id varchar2(13);      l_plan_hash_value number;  l_fixed varchar2(3);  l_enabled varchar2(3);  Begin    l_sql_id := '&&sql_id';   l_plan_hash_value := to_number('&&plan_hash_value');    l_fixed := 'Yes';    l_enabled := 'Yes';    ret := dbms_spm.load_plans_from_cursor_cache(        sql_id=>l_sql_id,        plan_hash_value=>l_plan_hash_value,        fixed=>l_fixed,        enabled=>l_enabled);    end;   /      select count(*) from dba_sql_plan_baselines ;       select SQL_HANDLE, PLAN_NAME from dba_sql_plan_baselines;      BEGIN   DBMS_SPM.CREATE_STGTAB_BASELINE(   table_name      => 'SPM_STAGETAB',   table_owner     => 'MONITOR',   tablespace_name => 'TOOLS'); END; DECLARE       my_plans number;       BEGIN         my_plans := DBMS