分类: Oracle
2008-04-17 15:24:37
10g中表监控与statistics_level |
作者 xzh2000 19:53 | 静态链接网址 | 最新回复 (5) | 引用 (0) | 技术交流 |
在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的新功能: 监控结果是自上次统计收集以来大概的INSERT/UPDATE/DELETE的记录数,当然这也与sga中维护的记录数有关,每15分钟,smon会刷新统计结果到数据字典中,可以通过如下DBA/ALL/USER_TAB_MODIFICATIONS数据字典查看监控结果,如果想立即看到监控结果,可以用exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO()来刷新数据到数据字典中,oracle使用这些表的数据去判断表的统计数据是否过期,如果当表的数据改变超过10%,oracle就认为该表的统计数据已经过期. Example: Step 1: Create table EMP. Its description is as follows SQL> desc emp COUNT(*) 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 SQL> insert into emp select * from emp; 14 rows created. 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 Step 5: If a monitored table has been modified more than 10%, then these Analyze the tables whose statistics have become stale using the following command: execute DBMS_STATS.GATHER_SCHEMA_STATS ('RAJIV', Step 6: Query dba_tab_modifications to check whether the table has been analyzed SQL> select * from user_tab_modifications; no rows selected No rows in dba_tab_modifications indicates that the table is analyzed. |