statistics_level 参数是oracle9.2开始引入的一个控制系统统计参数收集的一个开关.一共有三个值:basic,typical,all.支持alter session,alter system 动态修改.如果要用statspack或者AWR收集系统性能统计数据.那么这个参数的值必须为typical或all.通常all是一个全面收集,包括 OS以及sql执行路径方面的一些统计信息,除非遇见非常严重的性能问题或在一些特殊的性能挣断方面才会用到statistics_level=all, 平常statistics_level=typeical已经足够挣断99%的性能问题了.
example: seting statistics_level
alter system set statistics_level=basic;
alter system set statistics_level=typical;
alter system set statistics_level=all;
or
alter session set statistics_level=basic; alter session set statistics_level=typical; alter session set statistics_level=all; oracle 还提供了v$statistics_level视图用来记录各个参数下oracle可以收集的统计信息的类别: SQL> ALTER SYSTEM SET statistics_level=basic; System altered. SQL> SELECT statistics_name, 2 session_status, 3 system_status, 4 activation_level, 5 session_settable 6 FROM v$statistics_level 7 ORDER BY statistics_name; Session System Activation Session Statistics Name Status Status Level Settable —————————— ———- ———- ———- ———- Buffer Cache Advice DISABLED DISABLED TYPICAL NO MTTR Advice DISABLED DISABLED TYPICAL NO PGA Advice DISABLED DISABLED TYPICAL NO Plan Execution Statistics DISABLED DISABLED ALL YES Segment Level Statistics DISABLED DISABLED TYPICAL NO Shared Pool Advice DISABLED DISABLED TYPICAL NO Timed OS Statistics DISABLED DISABLED ALL YES Timed Statistics DISABLED DISABLED TYPICAL YES 8 rows selected. statistics_level=basic的情况下,oracle关闭了所有性能数据的收集,也就是如果要关闭AWR或statspack收集,只要设置alter system set statistics_level=basic;就行了; SQL> ALTER SYSTEM SET statistics_level=typical; System altered. SQL> SELECT statistics_name, 2 session_status, 3 system_status, 4 activation_level, 5 session_settable 6 FROM v$statistics_level 7 ORDER BY statistics_name; Session System Activation Session Statistics Name Status Status Level Settable —————————— ———- ———- ———- ———- Buffer Cache Advice ENABLED ENABLED TYPICAL NO MTTR Advice ENABLED ENABLED TYPICAL NO PGA Advice ENABLED ENABLED TYPICAL NO Plan Execution Statistics DISABLED DISABLED ALL YES Segment Level Statistics ENABLED ENABLED TYPICAL NO Shared Pool Advice ENABLED ENABLED TYPICAL NO Timed OS Statistics DISABLED DISABLED ALL YES Timed Statistics ENABLED ENABLED TYPICAL YES 8 rows selected. statistics_level=typical的时 候,除了plan_executetion_statistics和OS Statistics不能收集外,其他的都可以收集,如要要收集这个两项,必须设置statistics_level=all;
SQL> ALTER SYSTEM SET statistics_level=all; System altered. SQL> SELECT statistics_name, 2 session_status, 3 system_status, 4 activation_level, 5 session_settable 6 FROM v$statistics_level 7 ORDER BY statistics_name; Session System Activation Session Statistics Name Status Status Level Settable —————————— ———- ———- ———- ———- Buffer Cache Advice ENABLED ENABLED TYPICAL NO MTTR Advice ENABLED ENABLED TYPICAL NO PGA Advice ENABLED ENABLED TYPICAL NO Plan Execution Statistics ENABLED ENABLED ALL YES Segment Level Statistics ENABLED ENABLED TYPICAL NO Shared Pool Advice ENABLED ENABLED TYPICAL NO Timed OS Statistics ENABLED ENABLED ALL YES Timed Statistics ENABLED ENABLED TYPICAL YES 如果当statistics_level=ALL,系统收集所有的统计信息. from:http://blog.csdn.net/zengmuansha/article/details/5149398