作者:Alizze
手动革新Buffer Cache次要的启事是为了肃清Cache关于测试的影响,以此促使Oracle重新执行物理访问。以下为具体的示例参考:
◆Oracle 9i里,Oracle供应了一个外部事件,用来逼迫革新Buffer Cache,它的语法如下:
alter session set events 'immediate trace name flush_cache level 1';
或许如下所示:
alter session set events = 'immediate trace name flush_cache';
◆异常我们也可以运用alter system零碎级来设置。
alter system set events = 'immediate trace name flush_cache';
◆ Oracle 10g里,Oracle供应一个新的特性,可以经由进程以下的呼吁来革新Buffer Cache:
alter system flush buffer_cache;
上面这个示例演示了革新Cache后的感化:
(1)起首我们来创立测试表
SQL> create table t as select * from dba_objects;
Table created.
SQL> analyze table t compute statistics;
Table analyzed.
SQL> select blocks,empty_blocks from dba_tables
2 where table_name='T' and owner='SYS';
BLOCKS EMPTY_BLOCKS---------- ------------
78 1
表T共有79个Block.
(2)x$bh
SQL> select count(*) from x$bh;
COUNT(*)
----------
14375SQL>
select count(*) from x$bh where state=0;
-- state =0 is free
COUNT(*)
----------
13960SQL>
alter system set events = 'immediate trace name flush_cache';
System altered.
SQL> select count(*) from x$bh where state=0;
COUNT(*)
----------
14375
在这里你可以发现flush_cache今后,全数的Buffer都被标记为free。
(3)最初请细致flush_cache关于盘诘的影响
SQL> set autotrace trace stat
SQL> select count(*) from t;
Statistics
----------------------------------
0 recursive calls
0 db block gets
81 consistent gets
79 physical reads
0 redo size
....
SQL>
SQL> select count(*) from t;
Statistics-----------------------
0 recursive calls
0 db block gets
81 consistent gets
0 physical reads
0 redo size
....
SQL> alter system set events = 'immediate trace name flush_cache';
System altered.SQL> select count(*) from t;
Statistics
---------------------------------- 0 recursive calls
0 db block gets
81 consistent gets
79 physical reads
0 redo size
....
SQL>
版权声明:
原创作品,许愿转载,转载时请务必以超链接体式式子标明文章 原始出处 、作者信息和本声明。不然将清查司法责任。