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,
scope IN VARCHAR2 := SCOPE_COMPREHENSIVE,
time_limit IN NUMBER := TIME_LIMIT_DEFAULT,
task_name IN VARCHAR2 := 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,
plan_hash_value IN NUMBER := NULL,
scope IN VARCHAR2 := SCOPE_COMPREHENSIVE,
time_limit IN NUMBER := TIME_LIMIT_DEFAULT,
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;
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341