Sub Pool数量受以下几个因素的影响: 系统CPU的数量.默认情况下,在Oracle中每4个CPU分配一个Sub Pool,最多不能超过7个.共享池的大小.Sub Pool的最小容量随着Oracle版本的不同而不同
9i 128M10g<10.2.0.3 256M10.2.0.3 and higher 512M 隐含参数_kghdsidx_count值.当 数据库启动时, Oracle优先根据_kghdsidx_count隐含参数设置Sub Pool数量.通过Dump Heap可以观察Sub Pool的数量,以下为Oracle 9i的四个Sub Pool
Oracle的思路是通过多CPU的特性来将一个很大的共享池划分为若干个对等的功能区,每个独立的区间都有相同的管理机制,可以并发访问,从而解决性能发面的瓶颈. 在具有子池的情况下,Oracle在共享池中分配空间的算法也会发生一些改变.比如在没有共享池的情况下,如果想在共享池中分配空间,必须先持有Shared Pool Latch,如果无法获得Latch,就需要等待.而在有子池的情况下,算法发生了改变.如果某个
系统的共享池有6个子池,那么申请共享池?锁可以从0号子池开始,一直到5号子池,每个子池都有一个共享池子闩锁.在申请0~4号共享池子闩锁的时候,采用不需要等待模式,一旦申请失败,不需要等待,直接返回;而申请5号子池的共享池子闩锁的时候,就需要采用等待模式,直到获得这个闩锁为止.
从Oracle 10g开始,每个Sub Pool由四个Sub Partition组成,如下所示: cat PROD_ora_20486.trc|grep "sga heap"
HEAP DUMP heap name="sga heap" desc=0x200010b4
HEAP DUMP heap name="sga heap(1,0)" desc=0x2002b1cc
HEAP DUMP heap name="sga heap(1,1)" desc=0x2002be04
HEAP DUMP heap name="sga heap(1,2)" desc=0x2002ca3c
HEAP DUMP heap name="sga heap(1,3)" desc=0x2002d674
HEAP DUMP heap name="sga heap(2,0)" desc=0x200306f4
HEAP DUMP heap name="sga heap(2,1)" desc=0x2003132c
HEAP DUMP heap name="sga heap(2,2)" desc=0x20031f64
HEAP DUMP heap name="sga heap(2,3)" desc=0x20032b9c
Sub Partition的出现跟Shared Pool Duration的特性有关,其特性有隐含参数_enable_shared_pool_durations决定,默认为TRUE,即启用Shared Pool Duration特性. 当_enable_shared_pool_durations被设置为FALSE时,Sub Partition在Sub Pool中消失.在Oracle 10g,如果设置SGA_TARGET为0,或者在Oracle 10.2.0.5之前的版本中把cursor_space_for_time设置为True时,——enable_shared_pool_duration自动被设置为False
至于这个Shared Pool Duration特性到底是啥?我没有百度出来,或者说百度出来的都是copy的,或者一带而过的.如果哪位直到,还请告诉我,谢谢
SUBPOOL BYTES MB
------------------------------------------------------ ---------- ----------
shared pool(1): 138412332 132
shared pool(2): 121639208 116
shared pool(Total): 260051540 248
查看各个子池剩余内存 sys@PROD>select subpool,name,sum(bytes),round(sum(bytes)/1048576,2) mb from (select 'shared pool(' || decode(to_char(ksmdsidx), '0','0-Unused',ksmdsidx) || '):' subpool,ksmssnam name,ksmsslen bytes from x$ksmss where ksmsslen>0 and lower(ksmssnam) like lower('%free memory%')) group by subpool,name order by subpool asc,sum(bytes) desc;
SUBPOOL NAME SUM(BYTES) MB
------------------------------------------------------ -------------------------- ---------- ----------
shared pool(0-Unused): free memory 79691776 76
shared pool(1): free memory 10876920 10.37
shared pool(2): free memory 13165708 12.56
通过X$KGHLU查看各SUB POOL发生ORA-04031的情况 column indx heading "indx|indx num" column kghlurcr heading "RECURRENT|CHUNK" column kghlutrn heading "TRANSIENT|CHUNK" column kghlufsh heading "FLUSHED|CHUNK" column kghluops heading "PINS AND|RELEASES" column kghlunfu heading "ORA-4031|ERRORS" column kghlunfs heading "LAST ERROR|SIZE" select indx,kghlurcr ,kghlutrn ,kghlufsh, kghluops, kghlunfu, kghlunfs from x$kghlu wh