35、10g中表监控与statistics_level

 

在10g之前的版本,必须用dbms_stats的ALTER_DATABASE/SCHEMA_TAB_MONITORING过程或者create/alter table ... monitoring打开表的监控,在10g中,MONITORING与NOMONITORING关键字已经过时,如果你在create/alter table中指定表的监控或取消监控,该关键字将忽略,表监控特征被statistics_level控制,当statistics_level等于basic时,将禁止表的监控,如果等于typical或all时,表监控是激活的.

 

statistics_level默认是typical,在10g中表监控是激活的,强烈建议在10g中此参数的值是typical.如果STATISTICS_LEVEL设置为basic,不仅不能监控表,而且将禁掉如下一些10g的新功能:
ASH(Active Session History)
ASSM(Automatic Shared Memory Management)
AWR(Automatic Workload Repository)
ADDM(Automatic Database Diagnostic Monitor)

监控结果是自上次统计收集以来大概的INSERT/UPDATE/DELETE的记录数,当然这也与sga中维护的记录数有关,每15分钟,smon会刷新统计结果到数据字典中,可以通过如下DBA/ALL/USER_TAB_MODIFICATIONS数据字典查看监控结果,如果想立即看到监控结果,可以用exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO()来刷新数据到数据字典中,oracle使用这些表的数据去判断表的统计数据是否过期,如果当表的数据改变超过10%,oracle就认为该表的统计数据已经过期.

Example:
--------
Let us take an example:

Step 1:
-------

Create table EMP. Its description is as follows

SQL> desc emp
SQL> select count(*) from emp;

COUNT(*)
----------
14

SQL> select * from user_tab_modifications;

no rows selected

Initially there are 14 rows in EMP.

Step 2:
-------

Set parameter STATISTICS_LEVEL='TYPICAL'

SQL> alter system set STATISTICS_LEVEL='TYPICAL';

System altered.

Step 3:
-------

Insert additional 14 rows. This will increase the data in EMP by 50% and
therefore the statistics in EMP will be regarded as stale by Oracle.

SQL> insert into emp select * from emp;

14 rows created.
SQL>commit;

Step 4:
-------

SQL> exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO();

PL/SQL procedure successfully completed.

SQL> select * from user_tab_modifications;

TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP TRU
------------------------------ ---------- ---------- ---------- --------- ---
EMP
14 0 0 16-OCT-03 NO

Step 5:
-------

If a monitored table has been modified more than 10%, then these
statistics are considered stale

Analyze the tables whose statistics have become stale using the following command:

execute DBMS_STATS.GATHER_SCHEMA_STATS ('RAJIV',
NULL,
FALSE,
'FOR ALL COLUMNS SIZE 1',
NULL,
'DEFAULT',
TRUE,
NULL,
NULL,
'GATHER STALE',
'LIST' );

Step 6:
-------

Query dba_tab_modifications to check whether the table has been analyzed
or not?

SQL> select * from user_tab_modifications;

no rows selected

No rows in dba_tab_modifications indicates that the table is analyzed.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值