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.
原文转自:http://blogread.cn/it/article/47