ORACLE SQL TUNING ADVISOR

前端之家收集整理的这篇文章主要介绍了ORACLE SQL TUNING ADVISOR前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
sql tunning advisor 使用的主要步骤:
1 建立tunning task
2 执行task
3 显示tunning 结果
4 根据建议来运行相应的调优方法 ----ADVISOR授权

1 基于sql文本建立任务

FUNCTION create_tuning_task(
sql_text IN CLOB,
bind_list IN sql_binds := NULL,
user_name IN VARCHAR2 := NULL,
scope IN VARCHAR2 := SCOPE_COMPREHENSIVE,
time_limit IN NUMBER := TIME_LIMIT_DEFAULT,
task_name IN VARCHAR2 := NULL,
description IN VARCHAR2 := NULL)
RETURN VARCHAR2;

2 基于sql_id建立任务
FUNCTION create_tuning_task(
sql_id IN VARCHAR2,
plan_hash_value IN NUMBER := NULL,
description IN VARCHAR2 := NULL)
RETURN VARCHAR2;

3 基于AWR快照间隔以及相应sql_ID建立任务
FUNCTION create_tuning_task(
begin_snap IN NUMBER,
end_snap IN NUMBER,
sql_id IN VARCHAR2,
ask_name IN VARCHAR2 := NULL,
description IN VARCHAR2 := NULL)
RETURN VARCHAR2;

案例:
DECLARE
MY_TASK_NAME VARCHAR2(30);
MY_sqlTEXT CLOB;
BEGIN
MY_sqlTEXT :=‘SELECT 1 from dual‘;
MY_TASK_NAME := DBMS_sqlTUNE.CREATE_TUNING_TASK(sql_TEXT => MY_sqlTEXT,
BIND_LIST=>sql_BINDS(ANYDATA.CONVERTNUMBER(9)),
USER_NAME => ‘NOAP‘,
SCOPE=>‘COMPREHENSIVE‘,
TIME_LIMIT => 600,
TASK_NAME => ‘sql_TUNING_TEST‘,
DESCRIPTION=>‘TUNING TASK‘
);
END;

BEGIN DBMS_sqlTUNE.EXECUTE_TUNING_TASK(‘sql_TUNING_TEST‘); END;SELECT status FROM USER_ADVISOR_TASKS WHERE task_name =‘sql_TUNING_TEST‘;SELECT DBMS_sqlTUNE.REPORT_TUNING_TASK(‘sql_TUNING_TEST‘) FROM DUAL;BEGIN dbms_sqltune.drop_tuning_task(‘sql_TUNING_TEST‘); END;

猜你在找的Oracle相关文章