1.Does undo buffer exists or changes will directly write to undo datafiles?
Undo blocks are database blocks, so they will sit in the buffer cache like others, eg
虽然无法控制undo buffer大小,但是可以查询到其大小,如下
SQL> select count(*)
2 from v$bh
3 where file# in (
4 select file#
5 from v$datafile
6 where name like '%UNDO%' ); COUNT(*)
----------
5473
2.Does redo contains both undo & redo related changes?
Yes. Any change to any block (undo or otherwise) is protected by redo (unless explicitly instructed not to)
3.If db crashes with uncommitted data in undo buffer it will get cleared automatically ,then we are able rollback database with redo ?
During instance restart, we do instance recovery. We use the redo logs to resurrect all the changes to database blocks, which *includes* undo blocks. Those undo blocks can then be used to undo any uncommitted transactions (ie, uncommitted at the time of the crash)
in memory undo is a change in the way we manage undo for some transactions. We usually put undo in a block as you generate it - with in memory undo (IMU) we put the undo into a data structure instead - this data structure is easier/faster to process by queries that need the undo for read consistency purposes or rolling back.
设计IMU控制的参数有:
_in_memory_undo Default is TRUE and enabled. To disable it change parameter to FALSE.
_imu_pools Default is 3 on some system. This sets the number of IMU pools. It is not related to memory allocation for IMU.
_recursuve_imu_transactions This enables Oracle’s own SQL to use IMU. Default is FALSE.
_db_writer_flush_imu Allows Oracle the freedom to artificially age a transaction for increased automatic cache management.
可以直接通过下列查询到IMU大小:
SQL> select * from v$sgastat where name like 'KTI-UNDO';
POOL NAME BYTES
------------ -------------------------- ----------
shared pool KTI-UNDO 8522272