Applies to:
Oracle Database - Personal Edition - Version 10.1.0.2 to 11.2.0.3 [Release 10.1 to 11.2]
Oracle Database - Enterprise Edition - Version 10.1.0.2 to 11.2.0.3 [Release 10.1 to 11.2]
Oracle Database - Standard Edition - Version 10.1.0.2 to 11.2.0.3 [Release 10.1 to 11.2]
Information in this document applies to any platform.
Any 10g and 11g release database is affected.
Starting with 10.1, the optimizer uses dynamic sampling when there are no statistics rather than defaulting to rule based optimization as previously. If the dynamic sampling is time consuming this can result in contention performance problems and possible 'hang-like' symptoms.
从10.1开始,当没有统计信息时,优化器使用采样统计信息而不是之前的RBO,如果动态采集消耗大量时间,会导致hang-like现象。
This may be expected behavior.
Latching on large fixed objects is expensive, so without proper statistics, performance degradation is expected when sub-optimal plans happen (in some cases, there are instance wide effects, such as effectively serializing access to the shared pool) . This is more prevalent in very large, or very busy systems, as the number of times the latch is requested, and/or the length of time the latch is held, will increase with load and volume in the X$ being queried through the views.
在x$表上的latch是非常昂贵的,所以如果没有适当的统计信息,性能下降是可想而知的(有些情况下,会对实例产生广泛的影响,例如对shared pool的序列访问)。在巨大,繁忙系统,大量latch请求时间,通过views查询x$表,latch 被hold住,是很普遍的。
As such, it is a standard recommendation to gather fixed objects statistics under load so the optimizer can determine optimal paths. Some load is required so that the database has representative volume/content for as many of the views as possible.
这样,标准的建议是收集x$表的统计信息,以便优化器决定更加好的路径。一些负载是必须的以便表示数据库的体积和内容尽可能的多的。
Note: performance degradation may be experienced while the statistics are gathering.
For example, if gathering of the fixed objects statistics is done under heavy load this can result in the exact same contention issues, leading to performance degradation or hangs.
当在收集统计信息的时候,性能下降可能是要经历的。例如,如果在系统高峰期收集统计信息,可能会导致竞争,使性能下降或hang住。
There are some cases where having no statistics on a fixed object may produce the best plans, but in general, better plans are achieved by gathering statistics on these tables than by not gathering statistics.
有些情况下没有统计信息会产生好的,但是大部分情况是,收集统计信息比没有统计信息更能产生好的执行计划。
The purpose of this note is to address how to plan for fixed object statistics needs and gathering.
SQL> select sysdate from dual; SYSDATE --------- 08-APR-09 SQL> select OWNER, TABLE_NAME, LAST_ANALYZED from dba_tab_statistics where table_name='X$KGLDP'; OWNER TABLE_NAME LAST_ANAL -------- ------------------------------ --------- SYS X$KGLDP 04-APR-09 SQL> shutdown immediate; ... SQL> startup ... Database mounted. Database opened. SQL> select OWNER, TABLE_NAME, LAST_ANALYZED from dba_tab_statistics where table_name='X$KGLDP'; OWNER TABLE_NAME LAST_ANAL -------- ------------------------------ --------- SYS X$KGLDP 04-APR-09
Note that the last analyzed data has stayed static even though the database has been re-started
Additionally, current Statistics can be recorded in a stats table and exported for reload later as follows:
SQL> truncate table my_user.stats_table; Table truncated. SQL> exec dbms_stats.export_fixed_objects_stats(stattab=>'STATS_TABLE', statown=>'MY_USER'); PL/SQL procedure successfully completed. SQL> select count(*) from my_user.stats_table; COUNT(*) ---------- 8846
Note:748251.1 EM Agent DBSNMP Using Up Excessive Temp Space In Database (Doc ID 748251.1)
can be witnessed because statistics are not representative, and can be resolved by gathering representative statistics.
SQL> select sysdate from dual; SYSDATE ------------------- 04/04/2009 12:01:48 SQL> !date Sat Apr 4 12:01:53 MST 2009 SQL> exec dbms_stats.delete_fixed_objects_stats(); PL/SQL procedure successfully completed. SQL> select OWNER, TABLE_NAME, LAST_ANALYZED from dba_tab_statistics where table_name='X$KGLDP'; OWNER TABLE_NAME LAST_ANALYZED -------- ------------------------------ ------------- SYS X$KGLDP SQL> exec dbms_scheduler.run_job('GATHER_STATS_JOB'); PL/SQL procedure successfully completed. SQL> select OWNER, TABLE_NAME, LAST_ANALYZED from dba_tab_statistics where table_name='X$KGLDP'; OWNER TABLE_NAME LAST_ANALYZED -------- ------------------------------ ------------- SYS X$KGLDP SQL> exec dbms_stats.gather_fixed_objects_stats(); PL/SQL procedure successfully completed. SQL> select OWNER, TABLE_NAME, LAST_ANALYZED from dba_tab_statistics where table_name='X$KGLDP'; OWNER TABLE_NAME LAST_ANALYZED -------- ------------------------------ ------------- SYS X$KGLDP 04/04/2009 13:09:54
Note: The example above was not performed sequentially so the timings are not realistic. The execution of the command did not take an hour as implied ! There were interruptions in between the steps in the test.
In 11g,the Automated statistics gathering job (GATHER_STATS_JOB) is replaced with "Automatic Maintenance Tasks ". See:
Note:743507.1 Why Has the GATHER_STATS_JOB been removed in 11g? (Doc ID 743507.1)
Fixed table statistics still need to be gathered separately:
Oracle Database Performance Tuning Guide
11g Release 2 (11.2)
Part Number E16638-04
Chapter 13 Managing Optimizer Statistics
"
You must manually collect statistics on fixed objects, such as the dynamic performance tables, using GATHER_FIXED_OBJECTS_STATS procedure. Fixed objects record current database activity. You should gather statistics when the database has representative activity.