转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11908921



正确答案:A

 

A.   正确。可以还原到之前的statistics。

可以按需要根据时间点恢复统计信息,还原到2天前的统计信息

gyj@OCM >execute dbms_stats.restore_table_stats ('GYJ','T1',sysdate –2);
 
PL/SQL procedure successfully completed

 

B、不正确,保鲜期修改为2天,起不到什么作用,达不到还原统计信息的要求。

SM/OPTSTAT:用于存储老版本的优化统计信息,在oracle10g中,在我们手动或自动更新统计信息使oracle选择了错误的执行计划。oracle10g是可以恢复旧版本的统计信息,这个统计信息默认保存31天.

 

gyj@OCM> SELECT dbms_stats.get_stats_history_retention FROM dual;

 

GET_STATS_HISTORY_RETENTION

---------------------------

                         31

修改SM/OPTSTAT的统计信息的保存时间为10

gyj@OCM>  execdbms_stats.alter_stats_history_retention(2);

 

PL/SQL procedure successfully completed.

 

gyj@OCM>  SELECTdbms_stats.get_stats_history_retention FROM dual;

 

GET_STATS_HISTORY_RETENTION

---------------------------

                          2


C、OPTIMIZER_USE_PENDING_STATISTICS 是挂起统计信息,不发布统信息

在Oracle中,存在一个参数optimizer_use_pending_statistics,用来控制当前是否使用pending的统计量来生成执行计划。作为运维DBA,可以通过这个参数暂时性的启用pending统计量,观察一下性能状况。再决定是否启用publish这些统计量。

默认情况下,该参数取值为false。我们可以在session级别设置下该参数为true。

在11g中提出的pendingstatistic的方法,可以在生产运维和稳定优化执行计划方面,给我们提供帮助。

gyj@OCM> show parameterSTATISTICS

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

optimizer_use_pending_statistics     boolean    FALSE

statistics_level                     string      TYPICAL

timed_os_statistics                  integer     0

timed_statistics                     boolean     TRUE

 

gyj@OCM> alter session setoptimizer_use_pending_statistics=true;

 

Session altered.

修改参数为true之后,Oracle CBO在生成执行计划的时候就会使用Pending的统计量。

D、减少AutomaticWorkload库(AWR)保留时间2天,默认AWR保留是7天,但AWR中这个统计信息与SQL执行生成所需要的统计信息不是一回事情。

EXECUTEDBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(

  interval =>  60,

  retention =>  20160);

retention

The new retention time (in minutes). The specified value must be in the range of MIN_RETENTION (1 day) to MAX_RETENTION (100 years).

If ZERO is specified, snapshots will be retained forever. A large system-defined value will be used as the retention setting.

If NULL is specified, the old value for retention is preserved.



QQ:252803295

技术交流QQ群:
DSI&Core Search  Ⅰ 群:127149411(2000人技术群:未满)
DSI&Core Search  Ⅱ 群:177089463(1000人技术群:未满)
DSI&Core Search  Ⅲ 群:284596437(500人技术群:未满)
DSI&Core Search  Ⅳ 群:192136702(500人技术群:未满)
DSI&Core Search  Ⅴ 群:285030382(500人闲聊群:未满)


MAIL:dbathink@hotmail.com

BLOG: http://blog.csdn.net/guoyjoe

WEIBO:http://weibo.com/guoyJoe0218

ITPUB: http://www.itpub.net/space-uid-28460966.html

OCM:   http://education.oracle.com/education/otn/YGuo.HTM