IMU Flush
IMU pool也是按照LRU算法管理的。当IMU pool没有足够空闲内存可分配时,会将buffer链上LRU段的buffer块flush出来。其他一些事件也会导致IMU flush的发生,如switch logfile、rollback。但是,尽管IMU pool是从shared pool中分配的,手动flush shared pool并不会导致IMU flush。当IMU flush发生时,也会将undo、redo数据批量写入。
HELLODBA.COM>conn demo/demo@ora11
Connected.
HELLODBA.COM>alter session set "_in_memory_undo"=true;
Session altered.
HELLODBA.COM>update tt set x=1;
1 row updated.
HELLODBA.COM>update tt set x=2;
1 row updated.
HELLODBA.COM>update tt set x=3;
1 row updated.
HELLODBA.COM>select b.name, a.value from v$sysstat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
IMU commits 320
IMU Flushes 159
IMU contention 19
...
13 rows selected.
HELLODBA.COM>alter system switch logfile;
System altered.
HELLODBA.COM>select b.name, a.value from v$sysstat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
IMU commits 320
IMU Flushes 160
IMU contention 20
...
13 rows selected.
Connected.
HELLODBA.COM>alter session set "_in_memory_undo"=true;
Session altered.
HELLODBA.COM>update tt set x=1;
1 row updated.
HELLODBA.COM>update tt set x=2;
1 row updated.
HELLODBA.COM>update tt set x=3;
1 row updated.
HELLODBA.COM>select b.name, a.value from v$sysstat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
IMU commits 320
IMU Flushes 159
IMU contention 19
...
13 rows selected.
HELLODBA.COM>alter system switch logfile;
System altered.
HELLODBA.COM>select b.name, a.value from v$sysstat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
IMU commits 320
IMU Flushes 160
IMU contention 20
...
13 rows selected.
Tips: 通过dump出事务的undo block,可以比较IMU commit/flush前后undo block的变化——commit/flush之前没有写入数据。
IMU CR
在传统事务中,需要进行一致性读时,会从相应的UNDO数据块中读入undo数据进行undo操作。而在IMU中,在发生IMU commit或IMU flush之前,这些undo数据并未写入UNDO数据块中,此时一致性读就从IMU pool中读取相应的IMU node中的undo信息。
--Session 1:
HELLODBA.COM>conn demo/demo@ora11
Connected.
HELLODBA.COM>alter session set "_in_memory_undo"=true;
Session altered.
HELLODBA.COM>update tt set x=1;
1 row updated.
HELLODBA.COM>update tt set x=2;
1 row updated.
HELLODBA.COM>update tt set x=3;
1 row updated.
--Session 2:
HELLODBA.COM>conn demo/demo@ora11
Connected.
HELLODBA.COM>alter system flush buffer_cache;
System altered.
HELLODBA.COM>alter session set tracefile_identifier=IMU_CR;
Session altered.
HELLODBA.COM>alter session set events '10046 trace name context forever, level 8';
Session altered.
HELLODBA.COM>select * from tt;
X
----------
3
HELLODBA.COM>alter session set events '10046 trace name context off';
Session altered.
HELLODBA.COM>select b.name, a.value from v$mystat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
...
IMU CR rollbacks 3
...
13 rows selected.
HELLODBA.COM>conn demo/demo@ora11
Connected.
HELLODBA.COM>alter session set "_in_memory_undo"=true;
Session altered.
HELLODBA.COM>update tt set x=1;
1 row updated.
HELLODBA.COM>update tt set x=2;
1 row updated.
HELLODBA.COM>update tt set x=3;
1 row updated.
--Session 2:
HELLODBA.COM>conn demo/demo@ora11
Connected.
HELLODBA.COM>alter system flush buffer_cache;
System altered.
HELLODBA.COM>alter session set tracefile_identifier=IMU_CR;
Session altered.
HELLODBA.COM>alter session set events '10046 trace name context forever, level 8';
Session altered.
HELLODBA.COM>select * from tt;
X
----------
3
HELLODBA.COM>alter session set events '10046 trace name context off';
Session altered.
HELLODBA.COM>select b.name, a.value from v$mystat a, v$statname b where a.statistic#=b.statistic# and b.name like '%IMU%';
NAME VALUE
---------------------------------------------------------------- ----------
...
IMU CR rollbacks 3
...
13 rows selected.
从trace文件可以看到,我们将buffer cache的内容都flush了,但是并未从undo文件中读取undo 信息(没有相应的IO等待)。