Oracle中的IMU詳解

1、概述 oracle 10g InMemory Undo新特性: 通過以前的介紹,可知道Undo的管理方式和常規的數據管理方式是相同的,當進行數據修改時,會在Buffer中創建前鏡像,同時會記錄相應的Redo,然后這些Undo數據同樣會寫出到UNDO SEGMENT上,當進行一致性讀或回滾時,

1、概述

Oracle 10g InMemory Undo新特性:

通過以前的介紹,可知道Undo的管理方式和常規的數據管理方式是相同的,當進行數據修改時,會在Buffer中創建前鏡像,同時會記錄相應的Redo,然后這些Undo數據同樣會寫出到UNDO SEGMENT上,當進行一致性讀或回滾時,可能會產生大量的consistentgets和physical reads。注意到這里,Undo會產生Redo信息,又會寫UNDO SEGMENT,進而又可能產生大量讀取I/O,這些都是資源密集型操作。如果能夠縮減Undo在這些環節的Redo與Undo寫出,那么顯然就可以極大地提升數據庫性能,減少資源的消耗和使用。

從Oracle10g開始,Oracle在數據庫中引入了In Memory Undo(可以被縮寫為IMU)的新技術,使用這一技術,數據庫會在共享內存中(Shared Pool)開辟獨立的內存區域用于存儲Undo信息,這樣就可以避免Undo信息以前在Buffer Cache中的讀寫操作,從而可以進一步的減少Redo生成,同時可以大大減少以前的UNDO SEGMENT的操作。IMU中數據通過暫存、整理與收縮之后也可以寫出到回滾段,這樣的寫出提供了有序、批量寫的性能提升。

IMU機制與前面日志提到的PVRS緊密相關,由于每個IMU Buffer的大小在64~128KB左右,所以僅有特定的小事務可以使用,每個事務會被綁定到一個獨立的空閑的IMU Buffer,同時相關的Redo信息會寫入PVRS中,同樣每個IMU Buffer會由一個獨立的In Memory Undo Latch保護,當IMU Buffer或PVRS寫滿之后,數據庫需要寫出IMU中的信息。

一個新引入的隱含參數可以控制該特性是否啟用,這個參數是_in_memory_undo,在Oracle 10g中這個參數的缺省值是TRUE(不同版本和平臺參數的初始設置可能不同):

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的內存在Shared Pool中分配,回想一下Redo Log Buffer的內存使用與功能,實際上IMU技術在某種程度上也是參考了Log Buffer的機制,通過以下查詢可以獲得系統當前分配的IMU內存:

sys@TQGZS> select * from v$sgastat where name =’KTI-UNDO’;
POOL??????? NAME?????????????????????????????? BYTES
———— —————————— ———-
shared pool KTI-UNDO???????????????????????? 1235304

In Memory Undo池缺省的會分配3個,用以提供更好的并發:

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的使用信息,如提交次數可以通過V$SYSSTAT視圖查詢:

sys@TQGZS> select name,value from v$sysstat where name like ‘%commits’;
NAME????????????????????????????????? VALUE
—————————— ————-
usercommits?????????????????????????? 2877
IMUcommits??????????????????????????? 1549

新的內存Buffer通過In Memory Undo Latch來進行保護:

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.

除了前面提到的,還有幾個隱含參數與IMU有關:
·_recursive_imu_transactions:控制遞歸事務是否使用IMU,該參數缺省值為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事務的降級為常規事務,并執行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環境中,IMU不被支持。

經過不同版本Oracle技術的不斷演進,Oracle的內存管理已經和以前大為不同,現在Buffer Cache、Shared Pool、Log Buffer的內容正在不斷交換滲透,Redo、Undo數據都可以部分地存儲在共享池中,Oracle 11g的Result Cache也被記錄在Shared Pool當中。

– The End –

? 版權聲明
THE END
喜歡就支持一下吧
點贊15 分享