,这里我们来搞清楚_kghdsidx_count 与 subpool 以及subpool中的分区( 实际是duration)的关系:
SQL> select * from v$version;BANNER----------------------------------------------------------------Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64biPL/SQL Release 10.2.0.5.0 - ProductionCORE 10.2.0.5.0 ProductionTNS for Linux: Version 10.2.0.5.0 - ProductionNLSRTL Version 10.2.0.5.0 - ProductionSQL> set linesize 200 pagesize 1400SQL> show parameter kghNAME TYPE VALUE------------------------------------ -------------------------------- ------------------------------_kghdsidx_count integer 7SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 536870914;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_11783.trc[oracle@vrh8 dbs]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_11783.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x60036110FIVE LARGEST SUB HEAPS for heap name="sga heap(1,0)" desc=0x60036110HEAP DUMP heap name="sga heap(2,0)" desc=0x6003f938FIVE LARGEST SUB HEAPS for heap name="sga heap(2,0)" desc=0x6003f938HEAP DUMP heap name="sga heap(3,0)" desc=0x60049160FIVE LARGEST SUB HEAPS for heap name="sga heap(3,0)" desc=0x60049160HEAP DUMP heap name="sga heap(4,0)" desc=0x60052988FIVE LARGEST SUB HEAPS for heap name="sga heap(4,0)" desc=0x60052988HEAP DUMP heap name="sga heap(5,0)" desc=0x6005c1b0FIVE LARGEST SUB HEAPS for heap name="sga heap(5,0)" desc=0x6005c1b0HEAP DUMP heap name="sga heap(6,0)" desc=0x600659d8FIVE LARGEST SUB HEAPS for heap name="sga heap(6,0)" desc=0x600659d8HEAP DUMP heap name="sga heap(7,0)" desc=0x6006f200FIVE LARGEST SUB HEAPS for heap name="sga heap(7,0)" desc=0x6006f200SQL> alter system set "_kghdsidx_count"=6 scope=spfile;System altered.SQL> startup force;ORACLE instance started.Total System Global Area 859832320 bytesFixed Size 2100104 bytesVariable Size 746587256 bytesDatabase Buffers 104857600 bytesRedo Buffers 6287360 bytesDatabase mounted.Database opened.SQL> SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 536870914;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_11908.trc[oracle@vrh8 dbs]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_11908.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x600360f0FIVE LARGEST SUB HEAPS for heap name="sga heap(1,0)" desc=0x600360f0HEAP DUMP heap name="sga heap(2,0)" desc=0x6003f918FIVE LARGEST SUB HEAPS for heap name="sga heap(2,0)" desc=0x6003f918HEAP DUMP heap name="sga heap(3,0)" desc=0x60049140FIVE LARGEST SUB HEAPS for heap name="sga heap(3,0)" desc=0x60049140HEAP DUMP heap name="sga heap(4,0)" desc=0x60052968FIVE LARGEST SUB HEAPS for heap name="sga heap(4,0)" desc=0x60052968HEAP DUMP heap name="sga heap(5,0)" desc=0x6005c190FIVE LARGEST SUB HEAPS for heap name="sga heap(5,0)" desc=0x6005c190HEAP DUMP heap name="sga heap(6,0)" desc=0x600659b8FIVE LARGEST SUB HEAPS for heap name="sga heap(6,0)" desc=0x600659b8SQL> SQL> alter system set "_kghdsidx_count"=2 scope=spfile;System altered.SQL> SQL> startup force;ORACLE instance started.Total System Global Area 851443712 bytesFixed Size 2100040 bytesVariable Size 738198712 bytesDatabase Buffers 104857600 bytesRedo Buffers 6287360 bytesDatabase mounted.Database opened.SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 2;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_12003.trc[oracle@vrh8 ~]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_12003.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x600360b0HEAP DUMP heap name="sga heap(2,0)" desc=0x6003f8dSQL> alter system set cpu_count=16 scope=spfile;System altered.SQL> startup force;ORACLE instance started.Total System Global Area 851443712 bytesFixed Size 2100040 bytesVariable Size 738198712 bytesDatabase Buffers 104857600 bytesRedo Buffers 6287360 bytesDatabase mounted.Database opened.SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 2;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_12065.trc[oracle@vrh8 ~]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_12065.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x600360b0HEAP DUMP heap name="sga heap(2,0)" desc=0x6003f8d8SQL> show parameter sga_targetNAME TYPE VALUE------------------------------------ -------------------------------- ------------------------------sga_target big integer 0SQL> alter system set sga_target=1000M scope=spfile;System altered.SQL> startup force;ORACLE instance started.Total System Global Area 1048576000 bytesFixed Size 2101544 bytesVariable Size 738201304 bytesDatabase Buffers 301989888 bytesRedo Buffers 6283264 bytesDatabase mounted.Database opened.SQL> alter system set sga_target=1000M scope=spfile;System altered.SQL> startup force;ORACLE instance started.Total System Global Area 1048576000 bytesFixed Size 2101544 bytesVariable Size 738201304 bytesDatabase Buffers 301989888 bytesRedo Buffers 6283264 bytesDatabase mounted.Database opened.SQL> SQL> SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 2;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_12148.trcSQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@vrh8 dbs]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_12148.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x60036690HEAP DUMP heap name="sga heap(1,1)" desc=0x60037ee8HEAP DUMP heap name="sga heap(1,2)" desc=0x60039740HEAP DUMP heap name="sga heap(1,3)" desc=0x6003af98HEAP DUMP heap name="sga heap(2,0)" desc=0x6003feb8HEAP DUMP heap name="sga heap(2,1)" desc=0x60041710HEAP DUMP heap name="sga heap(2,2)" desc=0x60042f68_enable_shared_pool_durations:该参数控制是否启用10g中特有的shared pool duration特性,当我们设置sga_target为0时该参数为false;同时在10.2.0.5前若cursor_space_for_time设置为true时该参数也为false,不过在10.2.0.5以后cursor_space_for_time参数被废弃SQL> alter system set "_enable_shared_pool_durations"=false scope=spfile;System altered.SQL> SQL> startup force;ORACLE instance started.Total System Global Area 1048576000 bytesFixed Size 2101544 bytesVariable Size 738201304 bytesDatabase Buffers 301989888 bytesRedo Buffers 6283264 bytesDatabase mounted.Database opened.SQL> oradebug setmypid;Statement processed.SQL> oradebug dump heapdump 2;Statement processed.SQL> oradebug tracefile_name/s01/admin/G10R25/udump/g10r25_ora_12233.trcSQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options\[oracle@vrh8 dbs]$ grep "sga heap" /s01/admin/G10R25/udump/g10r25_ora_12233.trcHEAP DUMP heap name="sga heap" desc=0x60000058HEAP DUMP heap name="sga heap(1,0)" desc=0x60036690HEAP DUMP heap name="sga heap(2,0)" desc=0x6003feb8
结论: 1. _kghdsidx_count 控制了 shared pool subpool的数量, _kghdsidx_count的最大允许值是7 即最多 7个 shared pool subpool 2. 为什么会在一个 subpool中还有4个 sub partition 如: sga heap(1,0) sga heap(1,1) sga heap(1,2) sga heap(1,3) 这不是因为 cpu的数目 也不是因为_kghdsidx_count, 而是因为 在10g 中AUTO SGA 引入了 shared pool duration的概念, duration 分成4类:
- Session duration
- Instance duration (never freed)
- Execution duration (freed fastest)
- Free memory
引入了 shared pool duration的目的是 在10gR1中Shared Pool的shrink收缩操作存在一些缺陷,造成缺陷的原因是在该版本中Buffer Cache还没有能力共享使用一个granule,这是因为Buffer Cache的granule的尾部由granule header和Metadata(可能是buffer header或者RAC中的Lock Elements)拼接组成,在其尾部不容许存在空洞。另一个原因是当时的shared pool允许不同生命周期duration(以后会介绍)的chunk存放在同一个granule中,这造成共享池无法完全释放granule。到10gR2中通过对Buffer Cache Granule结构的修改允许在granule header和buffer及Metadata(buffer header或LE)存在缝隙,同时shared pool中不同duration的chunk将不在共享同一个granule,通过以上改进buffer cache与shared pool间的内存交换变得可行。此外在10gr2中streams pool也开始支持内存交换(实际根据不同的streams pool duration存在限制) reference : http://www.oracledatabase12g.com/archives/understanding-automatic-sga-memory-management.html