Tuning task created for specific a statement from the AWR.
DECLARE
l_sql_tune_task_id VARCHAR2(100);
BEGIN
l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
begin_snap => 36351,
end_snap => 37452,
sql_id => 'g2xhmn9fzz995',
scope => DBMS_SQLTUNE.scope_comprehensive,
time_limit => 60,
task_name => 'g2xhmn9fzz995_AWR_tuning_task',
description => 'Tuning task for statement g2xhmn9fzz995 in AWR.');
DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/
Execute the task
EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'g2xhmn9fzz995_AWR_tuning_task');
Get the result
SET LONG 10000;
SET PAGESIZE 1000
SET LINESIZE 200
SELECT DBMS_SQLTUNE.report_tuning_task('g2xhmn9fzz995_AWR_tuning_task') AS recommendations FROM dual;
SET PAGESIZE 24