Example Of Execute SQL Advisor

I like show a basic example (valid only for a single sql_id) of how to execute the SQL ADVISOR from command like. If you prefer a GUI interface you can use EM Console or SQL Developer.

 

i) Create the task but before explain;

time_limit: maximum duration in seconds for the tuning session

The scope:

LIMITED

SQL Tuning Advisor produces recommendations based on statistical checks, access path analysis, and SQL structure analysis. SQL profile recommendations are not generated.

COMPREHENSIVE

SQL Tuning Advisor carries out all the analysis it performs under limited scope plus SQL profiling.

 

DECLARE
  Output  VARCHAR2(100);
BEGIN
  Output := DBMS_SQLTUNE.create_tuning_task (
            sql_id      => '9v64r4s0n7znc',
            scope       => DBMS_SQLTUNE.scope_comprehensive,
            time_limit  => 500,
            task_name   => 'TAREA ANR 0x0000F2',
            description => 'Anr task for 9v64r4s0n7znc');
  DBMS_OUTPUT.put_line('Task created: ' || Output);
END;
/

 

ii) Execute the task;

EXEC DBMS_SQLTUNE.EXECUTE_TUNING_TASK(TASK_NAME => 'TAREA ANR 0x0000F2'); 

iii) Show the report;

SET LINESIZE 100
SET LONG 5000 
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK ('TAREA ANR 0x0000F2') FROM DUAL; 

For more information, please refer to the doc at the next link;

SQL ADVISOR Documentation

HTH – Antonio NAVARRO

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s