周二早上10点 我新建了张表T1并插入了10W条记录,系统什么时候会自动搜集统计信息?(周一~周五的统计信息运行时间是晚上10点到次日六点) 

解决方案 »

  1.   

    select * from dba_scheduler_jobs
      

  2.   

    select * from dba_scheduler_jobs where job_name='GATHER_STATS_JOB';
      

  3.   

    Oracle 10g 查询的时候,自动统计表的信息
      

  4.   

    select * from dba_scheduler_jobs where job_name='GATHER_STATS_JOB'
      

  5.   


    记得似乎不是这样,只有在表上没有统计信息或从上次收集至今该表的数据变动量超过10%时,oracle才会根据job去自动收集一次。oracle默认有个GATHER_STATS_JOB的job,在晚间10点到上午6点间进行统计信息收集,具体可以从下面这个视图里查到实际情况。
    SELECT * FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'GATHER_STATS_JOB';如下是《Performance Tuning Guide》里的内容
    14.2.1 GATHER_STATS_JOB
    Optimizer statistics are automatically gathered with the job GATHER_STATS_JOB. This job gathers statistics on all objects in the database which have:
    •Missing statistics
    •Stale statisticsThis job is created automatically at database creation time and is managed by the Scheduler. The Scheduler runs this job when the maintenance window is opened. By default, the maintenance window opens every night from 10 P.M. to 6 A.M. and all day on weekends.
    The GATHER_STATS_JOB job gathers optimizer statistics by calling the DBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC procedure. The GATHER_DATABASE_STATS_JOB_PROC procedure collects statistics on database objects when the object has no previously gathered statistics or the existing statistics are stale because the underlying object has been modified significantly (more than 10% of the rows).
      

  6.   

       等一个表没有统计的时候,等你查询的时候它会自动生成统计信息但不会把他存到user_tab_statistics中,什么时候才可以出发系统收集统计信息?一定要在select * from dba_scheduler_jobs where job_name='GATHER_STATS_JOB'的运行期间吗?
      

  7.   

    手动执行,统计表的信息:
    ANALYZE TABLE tablename COMPUTE STATISTICS