注意:對于未能獲取到Private strand的redo allocation latch的事務(wù),在事務(wù)結(jié)束前,即使已經(jīng)有其它事務(wù)釋放了Private strand,也不會再申請Private strand了。
每個Private strand的大小為65K。10g中,shared pool中的Private strands的大小就是活躍會話數(shù)乘以65K,而11g中,在shared pool中需要為每個Private strand額外分配4k的管理空間,即:數(shù)量*69k。
--10g: SQL> select * from V$sgastat where name like '%strand%'; POOL NAME BYTES ------------ -------------------------- ---------- shared pool private strands 1198080 HELLODBA.COM>select trunc(value * KSPPSTVL / 100) * 65 * 1024 2 from (select value from v$parameter where name = 'transactions') a, 3 (select val.KSPPSTVL 4 from sys.x$ksppi nam, sys.x$ksppsv val 5 where nam.indx = val.indx 6 AND nam.ksppinm = '_log_private_parallelism_mul') b; TRUNC(VALUE*KSPPSTVL/100)*65*1024 ------------------------------------- 1198080 --11g: HELLODBA.COM>select * from V$sgastat where name like '%strand%'; POOL NAME BYTES ------------ -------------------------- ---------- shared pool private strands 706560 HELLODBA.COM>select trunc(value * KSPPSTVL / 100) * (65 + 4) * 1024 2 from (select value from v$parameter where name = 'transactions') a, 3 (select val.KSPPSTVL 4 from sys.x$ksppi nam, sys.x$ksppsv val 5 where nam.indx = val.indx 6 AND nam.ksppinm = '_log_private_parallelism_mul') b; TRUNC(VALUE*KSPPSTVL/100)*(65+4)*1024 ------------------------------------- 706560 Private strand的數(shù)量受到2個方面的影響:logfile的大小和活躍事務(wù)數(shù)量。
參數(shù)_log_private_mul指定了使用多少logfile空間預(yù)分配給Private strand,默認為5。我們可以根據(jù)當前l(fā)ogfile的大小(要除去預(yù)分配給log buffer的空間)計算出這一約束條件下能夠預(yù)分配多少個Private strand:
HELLODBA.COM>select bytes from v$log where status = 'CURRENT'; BYTES ---------- 52428800 HELLODBA.COM>select trunc(((select bytes from v$log where status = 'CURRENT') - (select to_number(value) from v$parameter where name = 'log_buffer'))* 2 (select to_number(val.KSPPSTVL) 3 from sys.x$ksppi nam, sys.x$ksppsv val 4 where nam.indx = val.indx 5 AND nam.ksppinm = '_log_private_mul') / 100 / 66560) 6 as "calculated private strands" 7 from dual; calculated private strands -------------------------- 5 HELLODBA.COM>select count(1) "actual private strands" from x$kcrfstrand where last_buf_kcrfa = '00'; actual private strands ---------------------- 5 當logfile切換后(和checkpoint一樣,切換之前必須要將所有Private strand的內(nèi)容flush到logfile中,因此我們在alert log中可能會發(fā)現(xiàn)日志切換信息之前會有這樣的信息:"Private strand flush not complete",這是可以被忽略的),會重新根據(jù)切換后的logfile的大小計算對Private strand的限制:
HELLODBA.COM>alter system switch logfile; System altered. HELLODBA.COM>select bytes from v$log where status = 'CURRENT'; BYTES ---------- 104857600 HELLODBA.COM>select trunc(((select bytes from v$log where status = 'CURRENT') - (select to_number(value) from v$parameter where name = 'log_buffer'))* 2 (select to_number(val.KSPPSTVL) 3 from sys.x$ksppi nam, sys.x$ksppsv val 4 where nam.indx = val.indx 5 AND nam.ksppinm = '_log_private_mul') / 100 / 66560) 6 as "calculated private strands" 7 from dual; calculated private strands -------------------------- 13 HELLODBA.COM>select count(1) "actual private strands" from x$kcrfstrand where last_buf_kcrfa = '00'; actual private strands ---------------------- 13 參數(shù)_log_private_parallelism_mul用于推算活躍事務(wù)數(shù)量在最大事務(wù)數(shù)量中的百分比,默認為10。Private strand的數(shù)量不能大于活躍事務(wù)的數(shù)量。
HELLODBA.COM>show parameter transactions NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ transactions integer 222 transactions_per_rollback_segment integer 5 HELLODBA.COM>select trunc((select to_number(value) from v$parameter where name = 'transactions') * 2 (select to_number(val.KSPPSTVL) 3 from sys.x$ksppi nam, sys.x$ksppsv val 4 where nam.indx = val.indx 5 AND nam.ksppinm = '_log_private_parallelism_mul') / 100 ) 6 as "calculated private strands" 7 from dual; calculated private strands -------------------------- 22 HELLODBA.COM>select count(1) "actual private strands" from x$kcrfstrand where last_buf_kcrfa = '00'; actual private strands ---------------------- 22 注:在預(yù)分配Private strand時,會選擇上述2個條件限制下最小一個數(shù)量。但相應(yīng)的shared pool的內(nèi)存分配和redo allocation latch的數(shù)量是按照活躍事務(wù)數(shù)預(yù)分配的。
因此,如果logfile足夠大,_log_private_parallelism_mul與實際活躍進程百分比基本相符的話,Private strand的引入基本可以消除redo allocation latch的爭用問題。