oracle自动收集统计信息

oracle 18c中默认是打开的

select client_name,status from dba_autotask_client;

oracle自动收集统计信息_第1张图片

 如果要关闭或者打开的语法:

//打开
exec DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => ‘auto optimizer stats collection‘,operation => NULL,window_name => NULL);

//关闭
exec DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => ‘auto optimizer stats collection‘,operation => NULL,window_name => NULL);

查看当前自动收集统计信息的时间

 默认自动收集统计信息的时间为晚上10点(周一到周五,4个小时),早上6点(周六,周日,20个小时)

SELECT w.window_name,
w.repeat_interval,
w.duration,
w.enabled
FROM dba_autotask_window_clients c, dba_scheduler_windows w
WHERE c.window_name = w.window_name AND c.optimizer_stats = 'ENABLED';

oracle自动收集统计信息_第2张图片

关闭或开启某一天的自动收集:

//关闭
BEGIN
DBMS_AUTO_TASK_ADMIN.disable (
client_name   => 'auto optimizer stats collection',
operation     => NULL,
window_name   => 'MONDAY_WINDOW');
END;
/


//开启
BEGIN
DBMS_AUTO_TASK_ADMIN.enable (
client_name   => 'auto optimizer stats collection',
operation     => NULL,
window_name   => 'MONDAY_WINDOW');
END;
/

由于平时默认每天只收集4小时,时间有点短了,改成每天可收集8小时

begin

  --sys.dbms_scheduler.set_attribute(name => 'SYS.FRIDAY_WINDOW', attribute => 'repeat_interval', value => 'freq=daily;byday=FRI;byhour=1;byminute=0; bysecond=0');

  sys.dbms_scheduler.set_attribute(name => 'SYS.MONDAY_WINDOW', attribute => 'duration', value => '0 08:00:00');
  sys.dbms_scheduler.set_attribute(name => 'SYS.TUESDAY_WINDOW', attribute => 'duration', value => '0 08:00:00');
  sys.dbms_scheduler.set_attribute(name => 'SYS.WEDNESDAY_WINDOW', attribute => 'duration', value => '0 08:00:00');
  sys.dbms_scheduler.set_attribute(name => 'SYS.THURSDAY_WINDOW', attribute => 'duration', value => '0 08:00:00');
  sys.dbms_scheduler.set_attribute(name => 'SYS.FRIDAY_WINDOW', attribute => 'duration', value => '0 08:00:00');

end;

 

oracle自动收集统计信息_第3张图片

你可能感兴趣的:(ORACLE,18c,ORACLE,11G,oracle,数据库)