zoukankan      html  css  js  c++  java
  • Know more about shared pool subpool

    有同学在T.askmaclean.com上求助Shared Pool里SubPool子分区问题,这里我们来搞清楚_kghdsidx_count 与 subpool 以及subpool中的分区( 实际是duration)的关系:  
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    
    SQL> set linesize 200 pagesize 1400
    
    SQL> show parameter kgh
    
    NAME                                 TYPE                             VALUE
    ------------------------------------ -------------------------------- ------------------------------
    _kghdsidx_count                      integer                          7
    
    SQL> 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.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x60036110
    FIVE LARGEST SUB HEAPS for heap name="sga heap(1,0)"   desc=0x60036110
    HEAP DUMP heap name="sga heap(2,0)"  desc=0x6003f938
    FIVE LARGEST SUB HEAPS for heap name="sga heap(2,0)"   desc=0x6003f938
    HEAP DUMP heap name="sga heap(3,0)"  desc=0x60049160
    FIVE LARGEST SUB HEAPS for heap name="sga heap(3,0)"   desc=0x60049160
    HEAP DUMP heap name="sga heap(4,0)"  desc=0x60052988
    FIVE LARGEST SUB HEAPS for heap name="sga heap(4,0)"   desc=0x60052988
    HEAP DUMP heap name="sga heap(5,0)"  desc=0x6005c1b0
    FIVE LARGEST SUB HEAPS for heap name="sga heap(5,0)"   desc=0x6005c1b0
    HEAP DUMP heap name="sga heap(6,0)"  desc=0x600659d8
    FIVE LARGEST SUB HEAPS for heap name="sga heap(6,0)"   desc=0x600659d8
    HEAP DUMP heap name="sga heap(7,0)"  desc=0x6006f200
    FIVE LARGEST SUB HEAPS for heap name="sga heap(7,0)"   desc=0x6006f200
    
    SQL> alter system set "_kghdsidx_count"=6 scope=spfile;
    
    System altered.
    
    SQL> startup force;
    ORACLE instance started.
    
    Total System Global Area  859832320 bytes
    Fixed Size                  2100104 bytes
    Variable Size             746587256 bytes
    Database Buffers          104857600 bytes
    Redo Buffers                6287360 bytes
    Database 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.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x600360f0
    FIVE LARGEST SUB HEAPS for heap name="sga heap(1,0)"   desc=0x600360f0
    HEAP DUMP heap name="sga heap(2,0)"  desc=0x6003f918
    FIVE LARGEST SUB HEAPS for heap name="sga heap(2,0)"   desc=0x6003f918
    HEAP DUMP heap name="sga heap(3,0)"  desc=0x60049140
    FIVE LARGEST SUB HEAPS for heap name="sga heap(3,0)"   desc=0x60049140
    HEAP DUMP heap name="sga heap(4,0)"  desc=0x60052968
    FIVE LARGEST SUB HEAPS for heap name="sga heap(4,0)"   desc=0x60052968
    HEAP DUMP heap name="sga heap(5,0)"  desc=0x6005c190
    FIVE LARGEST SUB HEAPS for heap name="sga heap(5,0)"   desc=0x6005c190
    HEAP DUMP heap name="sga heap(6,0)"  desc=0x600659b8
    FIVE LARGEST SUB HEAPS for heap name="sga heap(6,0)"   desc=0x600659b8
    
    SQL> 
    SQL> alter system set "_kghdsidx_count"=2 scope=spfile;
    
    System altered.
    
    SQL> 
    SQL> startup force;
    ORACLE instance started.
    
    Total System Global Area  851443712 bytes
    Fixed Size                  2100040 bytes
    Variable Size             738198712 bytes
    Database Buffers          104857600 bytes
    Redo Buffers                6287360 bytes
    Database 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.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x600360b0
    HEAP DUMP heap name="sga heap(2,0)"  desc=0x6003f8d
    
    SQL> alter system set cpu_count=16 scope=spfile;
    
    System altered.
    
    SQL> startup force;
    ORACLE instance started.
    
    Total System Global Area  851443712 bytes
    Fixed Size                  2100040 bytes
    Variable Size             738198712 bytes
    Database Buffers          104857600 bytes
    Redo Buffers                6287360 bytes
    Database 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.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x600360b0
    HEAP DUMP heap name="sga heap(2,0)"  desc=0x6003f8d8
    
    SQL> show parameter sga_target
    
    NAME                                 TYPE                             VALUE
    ------------------------------------ -------------------------------- ------------------------------
    sga_target                           big integer                      0
    
    SQL> alter system set sga_target=1000M scope=spfile;
    
    System altered.
    
    SQL> startup force;
    ORACLE instance started.
    
    Total System Global Area 1048576000 bytes
    Fixed Size                  2101544 bytes
    Variable Size             738201304 bytes
    Database Buffers          301989888 bytes
    Redo Buffers                6283264 bytes
    Database 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 bytes
    Fixed Size                  2101544 bytes
    Variable Size             738201304 bytes
    Database Buffers          301989888 bytes
    Redo Buffers                6283264 bytes
    Database 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.trc
    SQL> 
    SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@vrh8 dbs]$ grep "sga heap"  /s01/admin/G10R25/udump/g10r25_ora_12148.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x60036690
    HEAP DUMP heap name="sga heap(1,1)"  desc=0x60037ee8
    HEAP DUMP heap name="sga heap(1,2)"  desc=0x60039740
    HEAP DUMP heap name="sga heap(1,3)"  desc=0x6003af98
    HEAP DUMP heap name="sga heap(2,0)"  desc=0x6003feb8
    HEAP DUMP heap name="sga heap(2,1)"  desc=0x60041710
    HEAP 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 bytes
    Fixed Size                  2101544 bytes
    Variable Size             738201304 bytes
    Database Buffers          301989888 bytes
    Redo Buffers                6283264 bytes
    Database 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.trc
    SQL> 
    SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options\
    
    [oracle@vrh8 dbs]$ grep "sga heap"   /s01/admin/G10R25/udump/g10r25_ora_12233.trc
    HEAP DUMP heap name="sga heap"  desc=0x60000058
    
    HEAP DUMP heap name="sga heap(1,0)"  desc=0x60036690
    HEAP 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
  • 相关阅读:
    读书思维导图
    19/12/19 最近计划
    搭建自己的终极框架
    Win10下安装erl和RabbitMQ踩坑【版本不兼容】
    这里的博客不再更新了,有兴趣的可以转移到我的新博客地址 https://spacesec.github.io/
    最新最全的sqlmap命令中文详解以及插件功能详解[最全]
    Listary:放弃笨拙且丑陋的文件查找系统吧
    自己写一个破解zip加密文件的脚本
    分享一下第一次和别人开发项目的心得
    如何进行git 的push操作
  • 原文地址:https://www.cnblogs.com/macleanoracle/p/2968308.html
Copyright © 2011-2022 走看看