1、概述 oracle 10g InMemory Undo新特性: 通過以前的介紹,可知道Undo的管理方式和常規(guī)的數(shù)據(jù)管理方式是相同的,當(dāng)進(jìn)行數(shù)據(jù)修改時(shí),會在Buffer中創(chuàng)建前鏡像,同時(shí)會記錄相應(yīng)的Redo,然后這些Undo數(shù)據(jù)同樣會寫出到UNDO SEGMENT上,當(dāng)進(jìn)行一致性讀或回滾時(shí),
1、概述
Oracle 10g InMemory Undo新特性:
通過以前的介紹,可知道Undo的管理方式和常規(guī)的數(shù)據(jù)管理方式是相同的,當(dāng)進(jìn)行數(shù)據(jù)修改時(shí),會在Buffer中創(chuàng)建前鏡像,同時(shí)會記錄相應(yīng)的Redo,然后這些Undo數(shù)據(jù)同樣會寫出到UNDO SEGMENT上,當(dāng)進(jìn)行一致性讀或回滾時(shí),可能會產(chǎn)生大量的consistentgets和physical reads。注意到這里,Undo會產(chǎn)生Redo信息,又會寫UNDO SEGMENT,進(jìn)而又可能產(chǎn)生大量讀取I/O,這些都是資源密集型操作。如果能夠縮減Undo在這些環(huán)節(jié)的Redo與Undo寫出,那么顯然就可以極大地提升數(shù)據(jù)庫性能,減少資源的消耗和使用。
從Oracle10g開始,Oracle在數(shù)據(jù)庫中引入了In Memory Undo(可以被縮寫為IMU)的新技術(shù),使用這一技術(shù),數(shù)據(jù)庫會在共享內(nèi)存中(Shared Pool)開辟獨(dú)立的內(nèi)存區(qū)域用于存儲Undo信息,這樣就可以避免Undo信息以前在Buffer Cache中的讀寫操作,從而可以進(jìn)一步的減少Redo生成,同時(shí)可以大大減少以前的UNDO SEGMENT的操作。IMU中數(shù)據(jù)通過暫存、整理與收縮之后也可以寫出到回滾段,這樣的寫出提供了有序、批量寫的性能提升。
IMU機(jī)制與前面日志提到的PVRS緊密相關(guān),由于每個(gè)IMU Buffer的大小在64~128KB左右,所以僅有特定的小事務(wù)可以使用,每個(gè)事務(wù)會被綁定到一個(gè)獨(dú)立的空閑的IMU Buffer,同時(shí)相關(guān)的Redo信息會寫入PVRS中,同樣每個(gè)IMU Buffer會由一個(gè)獨(dú)立的In Memory Undo Latch保護(hù),當(dāng)IMU Buffer或PVRS寫滿之后,數(shù)據(jù)庫需要寫出IMU中的信息。
一個(gè)新引入的隱含參數(shù)可以控制該特性是否啟用,這個(gè)參數(shù)是_in_memory_undo,在Oracle 10g中這個(gè)參數(shù)的缺省值是TRUE(不同版本和平臺參數(shù)的初始設(shè)置可能不同):
sys@TQGZS> @GetHidPar.sql
Enter value for par: _in_memory_undo
old?? 4: AND x.ksppinm LIKE ‘%&par%’
new?? 4: AND x.ksppinm LIKE ‘%_in_memory_undo%’
NAME????????????????????????? VALUE?????????????? DESCRIB
—————————— ——————————————————————————–
_in_memory_undo?????????????? TRUE??????????????? Make in memory undo for top level transactions
IMU的內(nèi)存在Shared Pool中分配,回想一下Redo Log Buffer的內(nèi)存使用與功能,實(shí)際上IMU技術(shù)在某種程度上也是參考了Log Buffer的機(jī)制,通過以下查詢可以獲得系統(tǒng)當(dāng)前分配的IMU內(nèi)存:
sys@TQGZS> select * from v$sgastat where name =’KTI-UNDO’;
POOL??????? NAME?????????????????????????????? BYTES
———— —————————— ———-
shared pool KTI-UNDO???????????????????????? 1235304
In Memory Undo池缺省的會分配3個(gè),用以提供更好的并發(fā):
sys@TQGZS> @GetHidPar.sql
Enter value for par: _imu_pool
old?? 4: AND x.ksppinm LIKE ‘%&par%’
new?? 4: AND x.ksppinm LIKE ‘%_imu_pool%’
NAME????????????????????????? VALUE?????????????? DESCRIB
—————————— ——————————————————————————–
_imu_pools??????????????????? 3?????????????????? in memory undo pools
IMU的使用信息,如提交次數(shù)可以通過V$SYSSTAT視圖查詢:
sys@TQGZS> select name,value from v$sysstat where name like ‘%commits’;
NAME????????????????????????????????? VALUE
—————————— ————-
usercommits?????????????????????????? 2877
IMUcommits??????????????????????????? 1549
新的內(nèi)存Buffer通過In Memory Undo Latch來進(jìn)行保護(hù):
sys@TQGZS> select name,gets,misses,immediate_gets,sleeps
? 2? from v$latch_children where name like ‘%undo latch’;
NAME??????????????????????????????? GETS???? MISSES IMMEDIATE_GETS??? SLEEPS
—————————— ———- ———- ————– ———-
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undo latch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 0???????? 0???????????? 0????????? 0
In memory undolatch?????????????????? 4???????? 0???????????? 2????????? 0
In memory undolatch???????????????? 214???????? 0???????????? 25???????? 0
In memory undolatch??????????????? 6118???????? 0?????????? 3064???????? 0
In memory undolatch??????????????? 4230???????? 0?????????? 1084???????? 0
In memory undolatch?????????????? 39583???????? 0????????? 2842????????? 0
18 rows selected.
除了前面提到的,還有幾個(gè)隱含參數(shù)與IMU有關(guān):
·_recursive_imu_transactions:控制遞歸事務(wù)是否使用IMU,該參數(shù)缺省值為False;
sys@TQGZS> @GetHidPar.sql
Enter value for par: _recursive_imu_transactions
old?? 4: AND x.ksppinm LIKE ‘%&par%’
new?? 4: AND x.ksppinm LIKE ‘%_recursive_imu_transactions%’
NAME????????????????????????? VALUE?????????????? DESCRIB
—————————— ——————————————————————————–
_recursive_imu_transactions?? FALSE?????????????? recursive transactions may be IMU
·_db_writer_flush_imu:控制是否允許DBWR將IMU事務(wù)的降級為常規(guī)事務(wù),并執(zhí)行UNDO SEGMENT的寫出操作,缺省值為TRUE。
sys@TQGZS> @GetHidPar.sql
Enter value for par: _db_writer_flush_imu
old?? 4: AND x.ksppinm LIKE ‘%&par%’
new?? 4: AND x.ksppinm LIKE ‘%_db_writer_flush_imu%’
NAME????????????????????????? VALUE?????????????? DESCRIB
—————————— ——————————————————————————–
_db_writer_flush_imu????????? TRUE??????????????? If FALSE, DBWR will not downgrade IMU txns for AGING
此外,在RAC環(huán)境中,IMU不被支持。
經(jīng)過不同版本Oracle技術(shù)的不斷演進(jìn),Oracle的內(nèi)存管理已經(jīng)和以前大為不同,現(xiàn)在Buffer Cache、Shared Pool、Log Buffer的內(nèi)容正在不斷交換滲透,Redo、Undo數(shù)據(jù)都可以部分地存儲在共享池中,Oracle 11g的Result Cache也被記錄在Shared Pool當(dāng)中。
– The End –