Friday, February 18, 2022

 Execute/Run Tuning Advisor from backend

step1 : login as sysdba or with user with tuning advisor priv

Step 2: Identify the sql for which you want to run tuning advisor

e.g I am using sql-id cxa9cy8vz51gw

step 3: Create Tuning Task

BEGIN

l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (

sql_id => 'cxa9cy8vz51gw',

scope => DBMS_SQLTUNE.scope_comprehensive,

time_limit => 500,

task_name => 'cxa9cy8vz51gw_tuning_task11',

description => 'Tuning task1 for statement cxa9cy8vz51gw');

DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);

END;

Step 4:Execute Tuning task:

EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'cxa9cy8vz51gw_tuning_task11');

Step 5: Get the Tuning advisor report.

set long 65536

set longchunksize 65536

set linesize 100

select dbms_sqltune.report_tuning_task('cxa9cy8vz51gw_tuning_task11') from dual;