Automatic SQL Tuning 学习
1.如果是非dba用户,要赋予advisor权限
2.创建tuning任务
使用在awr报表中发现有问题的sql进行tuning,还可以直接使用sql_id,cache cursor,sqlset(sql集)等方法
创建该tuning任务
SET SERVEROUTPUT ON
-- 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 => 369,
end_snap => 370,
sql_id => '3a13916h8yz59',
scope => DBMS_SQLTUNE.scope_comprehensive,
time_limit => 60,
task_name => '3a13916h8yz59_AWR_tuning_task',
description => 'Tuning task for statement 3a13916h8yz59 in AWR.');
DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/
3.执行tuning任务
EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => '3a13916h8yz59_AWR_tuning_task');
4.查看tuning任务的执行情况
select * from dba_advisor_log
如果发现该任务状态是COMPLETED的时候,表示tuning已经完成了
5.查看tuning的结果
select dbms_sqltune.report_tuning_task('3a13916h8yz59_AWR_tuning_task') from dual
阅读(1272) | 评论(0) | 转发(0) |