Oracle 10g中默認是對統計信息自動進行分析,每天22:00會啟動一個scheduler job來來進行,自動分析並不是說每天都去分析一遍所有表,只是分析rows改變超過10%的表,這是合理的,只分析很少一部分表。當然任何新特性存在都會有一定缺陷,關鍵看我們怎麼來用這個功能,至於是否要關閉自動分析,就要看你的需求和使用情況了。
--檢查是否開啟了自動分析
SQL> select t.owner,t.job_name,t.last_start_date,t.last_run_duration,t.next_run_date,t.comments
2 from dba_scheduler_jobs t where t.comments like \'%statistics collection%\'
3 ;
OWNER JOB_NAME LAST_START_DATE LAST_RUN_DURATION NEXT_RUN_DATE COMMENTS
SYS GATHER_STATS_JOB 17-OCT-07 10.00.03.137638 PM +08:00 +000000000 00:02:17.909439 Oracle defined automatic optimizer statistics collection job
SQL>
--關閉自動分析
db158:/home/oracle>$sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.3.0 - Production on Thu Oct 18 14:53:36 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> exec dbms_scheduler.disable(\'SYS.GATHER_STATS_JOB\') ;
PL/SQL procedure successfully completed.
--打開自動分析
SQL> exec dbms_scheduler.enable(\'SYS.GATHER_STATS_JOB\') ;
PL/SQL procedure successfully completed.