Oracle建议关闭自动统计任务中的STA以及段指导
Oracle建议关闭自动统计任务中的STA以及段指导
11g中默认启动了三个任务,分别是自动统计信息收集、自动段指导、STA,默认运行时间是周一到周五是运行4小时(22:00->次日2:00),周六日运行20小时(6:00->次日2:00)。
其中,STA以及段指导可以建议关闭,用处不大。而且必要时可以手工运行。
关于这几个任务的详细介绍网上够多就不介绍了。
查看任务状态:
col client_name for a35 select client_name,status from dba_autotask_client;
09:48:58 SYS@dbtest(826)> col client_name for a35 09:49:04 SYS@dbtest(826)> select client_name,status from dba_autotask_client; CLIENT_NAME STATUS ----------------------------------- ---------- auto optimizer stats collection ENABLED auto space advisor ENABLED sql tuning advisor ENABLED
禁用STA和段指导:
exec dbms_auto_task_admin.disable(client_name => 'sql tuning advisor',operation => NULL,window_name => NULL); exec dbms_auto_task_admin.disable (client_name => 'auto space advisor', operation => null, window_name => null); PL/SQL procedure successfully completed. select client_name,status from dba_autotask_client;
14:47:39 SYS@testdb(1203)> exec dbms_auto_task_admin.disable(client_name => 'sql tuning advisor',operation => NULL,window_name => NULL); PL/SQL procedure successfully completed. Elapsed: 00:00:00.05 14:50:20 SYS@testdb(1203)> exec dbms_auto_task_admin.disable (client_name => 'auto space advisor', operation => null, window_name => null); PL/SQL procedure successfully completed. Elapsed: 00:00:00.00 15:02:28 SYS@testdb(1203)> select client_name,status from dba_autotask_client; CLIENT_NAME STATUS ----------------------------------- ------------------------ auto optimizer stats collection ENABLED auto space advisor DISABLED sql tuning advisor DISABLED Elapsed: 00:00:00.28
查看自动统计任务的3个任务实际执行内容:
set line 500 col PROGRAM_NAME for a35 col PROGRAM_ACTION for a100 select program_name,program_action from dba_scheduler_programs where program_name in (select upper(task_name) from DBA_AUTOTASK_TASK);
17:08:56 SYS@testdb(89)> select program_name,program_action from dba_scheduler_programs where program_name in (select upper(task_name) from DBA_AUTOTASK_TASK); PROGRAM_NAME PROGRAM_ACTION ----------------------------------- ---------------------------------------------------------------------------------------------------- AUTO_SQL_TUNING_PROG DECLARE ename VARCHAR2(30); BEGIN ename := dbms_sqltune.execute_tuning_task( 'SYS_AUTO_SQL_TUNING_TASK'); END; AUTO_SPACE_ADVISOR_PROG dbms_space.auto_space_advisor_job_proc GATHER_STATS_PROG dbms_stats.gather_database_stats_job_proc Elapsed: 00:00:00.01
因此有,
手工执行系统STA:
exec dbms_sqltune.execute_tuning_task('SYS_AUTO_SQL_TUNING_TASK');
查看STA结果:
select dbms_sqltune.report_tuning_task('SYS_AUTO_SQL_TUNING_TASK') from dual;
手工执行段指导:
exec dbms_space.auto_space_advisor_job_proc;
查询段指导结果:
select tablespace_name, segment_name, segment_type, recommendations, c1 from table(dbms_space.asa_recommendations('TRUE', 'TRUE', 'FALSE'));