oracle数据库优化-11G⾃动维护任务autotask 通过⾃动创建job来⾃动维护任务。
SQL> select client_name,window_group ,a.status from dba_autotask_client a;
CLIENT_NAME WINDOW_GROUP STATUS
--------------------------------- ------------------------- --------
auto optimizer stats collection ORA$AT_WGRP_OS ENABLED
auto space advisor ORA$AT_WGRP_SA DISABLED
sql tuning advisor ORA$AT_WGRP_SQ DISABLED
新的管理包
SQL> desc sys.dbms_auto_task_admin
Element Type
--------------------- ---------
OPTFLG_DEFERRED CONSTANT
OPTFLG_IMMEDIATE CONSTANT
PRIORITY_MEDIUM CONSTANT
PRIORITY_HIGH CONSTANT
PRIORITY_URGENT CONSTANT
PRIORITY_CLEAR CONSTANT
LIGHTWEIGHT CONSTANT
HEAVYWEIGHT CONSTANT
VOLATILE CONSTANT
STABLE CONSTANT
SAFE_TO_KILL CONSTANT
DO_NOT_KILL CONSTANT
ATTRVAL_TRUE CONSTANT
ATTRVAL_FALSE CONSTANT
GET_P1_RESOURCES PROCEDURE
SET_P1_RESOURCES PROCEDURE
SET_CLIENT_SERVICE PROCEDURE
GET_CLIENT_ATTRIBUTES PROCEDURE
DISABLE PROCEDURE
ENABLE PROCEDURE
OVERRIDE_PRIORITY PROCEDURE
SET_ATTRIBUTE PROCEDURE
数据库优化sql语句
SQL>
窗⼝组包含的窗⼝如下:
SQL> select * From dba_scheduler_wingroup_members c where c.WINDOW_GROUP_NAME='ORA$AT_WGRP_SA';
WINDOW_GROUP_NAME WINDOW_NAME
------------------------------ ------------------------------
ORA$AT_WGRP_SA WEEKNIGHT_WINDOW
ORA$AT_WGRP_SA WEEKEND_WINDOW
ORA$AT_WGRP_SA MONDAY_WINDOW
ORA$AT_WGRP_SA TUESDAY_WINDOW
ORA$AT_WGRP_SA WEDNESDAY_WINDOW
ORA$AT_WGRP_SA THURSDAY_WINDOW
ORA$AT_WGRP_SA FRIDAY_WINDOW
ORA$AT_WGRP_SA SATURDAY_WINDOW
ORA$AT_WGRP_SA SUNDAY_WINDOW
9 rows selected
select client_name,window_name,to_char(e.WINDOW_START_TIME,'yyyy-mm-dd hh24:mi:ss')
stime,job_name,job_status from dba_autotask_job_history e
order by stime desc
1. ORACLE 11G⾃动维护任务
相关查询:
select window_name,
a1.RESOURCE_PLAN,
a1.start_date,
a1.duration,
a1.ENABLED
From dba_scheduler_windows a1;
select a2.CLIENT_NAME, a2.STATUS, a2.CONSUMER_GROUP
From dba_autotask_client a2;
select a3.WINDOW_name,
a3.WINDOW_NEXT_TIME,
a3.AUTOTASK_STATUS,
a3.OPTIMIZER_STATS,
a3.SEGMENT_ADVISOR,
a3.SQL_TUNE_ADVISOR
From dba_autotask_window_clients a3;
select *
From dba_rsrc_plan_directives
where plan = 'DEFAULT_MAINTENANCE_PLAN'
or plan like'%AUTOTASK%'
REASON="Stop job called because associated window was closed"
SQL> SELECT CLIENT_NAME,JOB_STATUS,JOB_DURATION FROM DBA_AUTOTASK_JOB_HISTORY WHERE
CLIENT_NAME='auto optimizer stats collection';
CLIENT_NAME
----------------------------------------------------------------
JOB_STATUS
------------------------------
JOB_DURATION
---------------------------------------------------------------------------
auto optimizer stats collection
SUCCEEDED
+000 02:02:28
1 ORACLE 11G ⾃动维护任务:
⾃动维护任务是⼀种按规则⾃动启动的数据库维护操作任务。⽐如⾃动收集为查询优化器使⽤的统计信息。⾃动维护任务按维护窗⼝⾃动运⾏。所谓⾃动维护窗⼝是按照预定义的间隔时间窗⼝。
oracle11g数据库有三种预定义的⾃动维护任务:
■ Automatic Optimizer Statistics Collection:
■ Automatic Segment Advisor
■ Automatic SQL Tuning Advisor(这个是oracle 11g新添加的⾃动维护任务)
缺省情况下,这三个任务配置为在所有维护窗⼝运⾏。
维护窗⼝:维护窗⼝是⼀个连续的时间间隔,⽤于管理⾃动维护任务所⽤。维护窗⼝是oracle 调度窗⼝,属于窗⼝组MAINTENANCE_WINDOW_GROUP。
1.2 配置⾃动维护任务:
1:启⽤和禁⽌维护任务:
使⽤DBMS_AUTO_ADMIN pl/sql包来启⽤或禁⽤任务:
禁⽤任务:
BEGIN
dbms_auto_task_admin.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
启⽤任务:
BEGIN
dbms_auto_able(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
这⾥client_name参数可以通过数据字典视图DBA_AUTOTASK_CLIENT来查询。
sys@ORCL11> select client_name from dba_autotask_client;
CLIENT_NAME
------------------------------------------------------------
auto optimizer stats collection
auto space advisor
sql tuning advisor
如果想启⽤或禁⽤所有窗⼝⾃动维护任务,调⽤ENABLE或DISABLE过程:
EXECUTE DBMS_AUTO_TASK_ADMIN.DISABLE;
1.3 为某⼀个维护窗⼝启⽤或禁⽤维护TASK
缺省情况下,所有维护任务在所有预定义的维护窗⼝都运⾏。可以对某⼀个维护窗⼝启⽤或禁⽤⾃动化任务。
BEGIN
dbms_auto_task_admin.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => 'MONDAY_WINDOW');
END;
上⾯的例⼦是对维护窗⼝monday_window进⾏禁⽤sql tuning advisor。
1.4 配置维护窗⼝:
对于当前打开的窗⼝,你需要⾸先禁⽤,然后修改再启⽤,配置⽴即⽣效,如果你不通过这三个过程来修改属性,属性是不会⽣效的,直到下⼀次窗⼝打开。
1.4.1 修改维护窗⼝
可是使⽤DBMS_SCHEDULER 包来修改窗⼝属性。
--先禁⽤维护窗⼝
BEGIN
dbms_scheduler.disable(
name => 'SATURDAY_WINDOW');
--修改维护窗⼝属性:
dbms_scheduler.set_attribute(
name => 'SATURDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(4, 'hour'));
--启⽤维护窗⼝
able(
name => 'SATURDAY_WINDOW');
END;
/
1.4.2 创建新窗⼝:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论