SlideShare ist ein Scribd-Unternehmen logo
1 von 59
SGA
    Internals

    Julian Dyke
    Independent Consultant

    Web Version

1   © 2005 Julian Dyke       juliandyke.com
Agenda
        Introduction
        SGA
           Granules
           Fixed SGA
           Buffer Cache
           Shared Pool
               Permanent Areas
               Heaps
               Subheaps
               Library Cache
               Reserved Area
           Log Buffer
        Conclusion


2   © 2005 Julian Dyke            juliandyke.com
Introduction
        Examples based on
           32 bit architecture
           Red Hat 2.1 AS
           Oracle 9.2.0.4
           Single (non-RAC) instance


        Examples affected by
           Oracle version
           Operating system
           Single instance / RAC
           Architecture (32/64)
           Parameters




3   © 2005 Julian Dyke                  juliandyke.com
Word Length
        Word length can be
          32 bit - 4 byte pointers
          64 bit - 8 byte pointers


        Also affects
           size of some integer variables e.g. int
           word alignment


        When moving from 32 bit to 64 bit Oracle recommends
         doubling
           SHARED_POOL_SIZE
           SHARED_POOL_RESERVED_SIZE
           LARGE_POOL_SIZE




4   © 2005 Julian Dyke                                juliandyke.com
Double Linked Lists - Insertion
           Frequently used in SGA structures
           Each element includes pointers to next and previous elements
           Requires 8 bytes (32 bit systems) or 16 bytes (64 bit systems)



                  5000F430      55443080       55845C54       52175AC0
           Head   5000F430
           Tail   5000F430




5     © 2005 Julian Dyke
    STOP
                                                          juliandyke.com
Double Linked Lists - Deletion
           Double linked lists are more efficient for
              insertion
              deletion




                  5000F430       55443080        55845C54     52175AC0
           Head   55443080       55845C54        52175AC0     5000F430
           Tail   52175AC0       5000F430        55443080     55845C54




6     © 2005 Julian Dyke
    STOP
                                                            juliandyke.com
Memory Areas
                                        08048000
          An Oracle process includes                  Executable
           the following memory areas
                                        0AAA28C0          PGA
                                                      Session Heap
              Executable
              PGA/Session Heap                          Shared
                                        40000000        Libraries
              Shared Libraries
              SGA
                                        50000000
              Stack                                      SGA




                                        584A4000


                                                         Stack


7     © 2005 Julian Dyke
    STOP
                                                   juliandyke.com
Shared Memory
        Shared memory can be dumped to trace file using

         $ sqlplus /nolog
         SQL> CONNECT SYS/<password> AS SYSDBA
         Connected
         SQL> ORADEBUG SETMYPID
                       ORADEBUG SETMYPID
         Statement processed
                       ORADEBUG IPC
         SQL> ORADEBUG IPC
         Information written to trace file
         SQL> ORADEBUG TRACEFILE_NAME
         /var/opt/oracle/admin/LX092001/udump/lx092001_ora_9824.trc




8   © 2005 Julian Dyke                              juliandyke.com
ORADEBUG IPC - Example
             Area #0 `Fixed Size' containing Subareas 0-0
              Total size 000000000006e5cc Minimum Subarea size 00000000
               Area Subarea     Shmid      Stable Addr      Actual Addr

                   0       0  163840 0x00000050000000 0x00000050000000
      Fixed Area                         Subarea size     Segment size
                                     000000000006f000 0000000008800000
            Area #1 `Variable Size' containing Subareas 1-1
             Total size 0000000008000000 Minimum Subarea size 00400000
              Area Subarea     Shmid      Stable Addr       Actual Addr
      Variable Area
                 1        1   163840 0x0000005006f000 0x0000005006f000
                                         Subarea size     Segment size
                                     0000000008391000 0000000008800000
           Area #2 `Redo Buffers' containing Subareas 2-2
             Total size 00000000000a3000 Minimum Subarea size 00000000
              Area Subarea     Shmid      Stable Addr       Actual Addr
                 2        2   163840 0x00000058400000 0x00000058400000
     Redo Buffers                        Subarea size     Segment size
                                     00000000000a3000 0000000008800000
            Area #3 `skgm overhead' containing Subareas 3-3
             Total size 0000000000001000 Minimum Subarea size 00000000
              Area Subarea     Shmid      Stable Addr       Actual Addr
                 3        3   163840 0x000000584a3000 0x000000584a3000
      OS Specific                        Subarea size     Segment size
                                     0000000000001000 0000000008800000
9     © 2005 Julian Dyke
    STOP
                                                        juliandyke.com
V$SGA
         Describes sizes of main components in SGA
         Used by SHOW SGA command in SQL*Plus

                   SELECT name, value FROM v$sga;

                          Name                  Value
                          Fixed Size           452044
                          Variable Size      83886080
                          Database Buffers   50331648
                          Redo Buffers         667648


         Based from X$KSMSD
         X$KSMSD derived from ksmstv_ (ksmst) in Fixed SGA



10   © 2005 Julian Dyke                                 juliandyke.com
Shared Global Area
         Contains
            Fixed SGA
            Buffer Pool
            Shared Pool                     Oracle 7.0 and above
            Large Pool                      Oracle 8.0 and above
            Java Pool                       Oracle 8.1.5 and above
            Streams Pool                    Oracle 10.1 and above
            Redo buffers


         Buffer Pool includes
            Default cache
            Keep and Recycle cache          Oracle 8.0 and above
            2K, 4K, 8K, 16K and 32K cache   Oracle 9.0.1 and above




11   © 2005 Julian Dyke                               juliandyke.com
Granules
         Introduced in Oracle 9.0.1

         SGA divided into granules

         In Oracle 9.2 granule size dependent on SGA_MAX_SIZE
            4 mb      SGA_MAX_SIZE <= 128 mb
            16 mb     SGA_MAX_SIZE > 128 mb

         If SGA_MAX_SIZE not set explicitly then defaults to sum of
          individual pool parameters

         SGA_MAX_SIZE cannot be dynamically modified




12   © 2005 Julian Dyke                                juliandyke.com
Granules
         Pool parameters rounded up to nearest granule

         Each pool occupies one or more granules

         Different buffer caches held in separate granules

         First "granule" contains
            Fixed SGA
            Granule directory
            Heap headers


         Last "granule" contains
            Guard pages
            Redo buffer
            Operating system specific overhead
            Remaining space unused



13   © 2005 Julian Dyke                                 juliandyke.com
Granules
         SGA_MAX_SIZE = 128M         4M   Fixed SGA 4M
         DB_CACHE_SIZE = 48M              Free 16M
         JAVA_POOL_SIZE = 20M
         LARGE_POOL_SIZE = 12M            Buffer Pool 48M
         SHARED_POOL_SIZE = 20M




                                   128M   Java Pool 20M


                                          Large Pool 12M


                                          Shared Pool 32M
         Note – shared pool size
         automatically increased          Redo Buffer 4M
         from 20M to 32M             4M


14 STOP 2005 Julian Dyke
     ©                                    juliandyke.com
Granule Operations
         The following pools can be dynamically resized
           Pool           Parameter                Version
           Shared Pool    SHARED_POOL_SIZE         9.0.1 and above
           Default        DB_CACHE_SIZE            9.0.1 and above
           2K             DB_2K_CACHE_SIZE         9.0.1 and above
           4K             DB_4K_CACHE_SIZE         9.0.1 and above
           8K             DB_8K_CACHE_SIZE         9.0.1 and above
           16K            DB_16K_CACHE_SIZE        9.0.1 and above
           32K            DB_32K_CACHE_SIZE        9.0.1 and above
           Keep           DB_KEEP_CACHE_SIZE       9.0.1 and above
           Recycle        DB_RECYCLE_CACHE_SIZE    9.0.1 and above
           Large Pool     LARGE_POOL_SIZE          9.2.0 and above
           Java Pool      JAVA_POOL_SIZE           10.1 and above

         Streams pool cannot be dynamically resized in Oracle 10.1

15   © 2005 Julian Dyke                                juliandyke.com
Granule Views
         The following views support dynamic memory management

         Introduced in Oracle 9.2
            V$SGA_DYNAMIC_COMPONENTS
            V$SGA_DYNAMIC_FREE_MEMORY
            V$SGA_CURRENT_RESIZE_OPS
            V$SGA_RESIZE_OPS
         Not always reliable

         Introduced in Oracle 10.1
            V$SGAINFO




16   © 2005 Julian Dyke                            juliandyke.com
X$KSMGE
      Introduced in Oracle 9.2
      Describes individual granules     Granule ID

        ADDR              RAW(4)         0   Free
                                         2   Shared Pool
        INDX              NUMBER         3   Large Pool
        INST_ID           NUMBER         4   Java Pool
                                         5   Buffer Pool
        GRANNUM           NUMBER
        GRANTYPE          NUMBER         INVALID (Free)
                                         ALLOCATED
        GRANSTATE         VARCHAR2(16)
        GRANFLAGS         NUMBER         Granule Address
        LOCALITY          NUMBER
                                         Granule Size
        BASEADDR          RAW(4)
        GRANSIZE          NUMBER         Next granule ID
        GRANNEXT          NUMBER
                                         Previous granule ID
        GRANPREV          NUMBER



17   © 2005 Julian Dyke                           juliandyke.com
Granule Dumps
         Granules can be dumped using

                 ALTER SESSION SET EVENTS
                 ‘immediate trace name granulelist level <level>’
         where <level> is

                          Heap                     Level
                          Null Granule               255
                          Home Granule               511
                          Shared Pool                767
                          Large Pool                1023
                          Java Pool                 1279
                          Buffer Cache              1535




18   © 2005 Julian Dyke                                    juliandyke.com
Fixed SGA
                              Area containing all fixed variables
                              Contains pointers to all other structures in SGA
                              Variable name, type, address and size
                               determined when Oracle executable is linked
                              Located at start of first granule of SGA


                                50000000
                                              Fixed SGA
                                5001D9E8   Granule Directory
                                5001DF50
                                            Heap Headers




19 STOP 2005 Julian Dyke
     ©                                                         juliandyke.com
X$KSMFSV
         Externalises name, type, address and size of all variables in
          fixed SGA
                                                         Name
                 ADDR              RAW(4)
                 INDX              NUMBER                Type
                 INST_ID           NUMBER
                                                         Address
                 KSMFSNAM          VARCHAR2(64)
                 KSMFSTYP          VARCHAR2(64)          Size
                 KSMFSADR          RAW(4)
                 KSMFSSIZ          NUMBER

         SGA can be dumped using

                          ORADEBUG FIXEDSGA




20   © 2005 Julian Dyke                                  juliandyke.com
Global Area Dumps
         Global areas can be dumped using

                 ALTER SESSION SET EVENTS
                 ‘immediate trace name global_area level <level>’
         where <level> is
                             Heap              Level
                             PGA                  1
                             SGA                  2
                             PGA + SGA            3
                             UGA                  4
                             PGA + UGA            5
                             SGA + UGA            6
                             PGA + SGA + UGA      7

         More detail is included at levels 0x08 0x10 0x18 (OR)

21   © 2005 Julian Dyke                                 juliandyke.com
X$KSMMEM
         Externalises contents of all locations in the SGA
                                                         Address
             ADDR            RAW(4)
             INDX            NUMBER
             INST_ID         NUMBER
                                                         Value
             KSMMMVAL        RAW(4)


         Does not work on Windows platforms




22   © 2005 Julian Dyke                                  juliandyke.com
Buffer Cache
                       51400000           DB_CACHE_SIZE = 48M
                       51800000           DB_BLOCK_SIZE = 8192
                       51C00000      Buffer Cache includes 12 x 4M granules
                       52000000      Each granule contains 500 buffers
                       52400000      Buffer Cache contains 6000 buffers
                       52800000
                                            Block     Buffers Per
                       52C00000             Size       Granule

                       53000000
                                                     4mb     16mb
                       53400000

                       53800000              2048    1875      7503
                                             4096     979      3916
                       53C00000
                                             8192     500      2002
                       54000000
                                             16384    253      1012
                                             32768    127       509
23     © 2005 Julian Dyke
     STOP
                                                            juliandyke.com
Buffer Headers
         Each buffer has a buffer header
         In 9.2.0.4 buffer headers are 188 bytes
         Buffer headers are stored in same granule as buffers
         Buffer headers include
            Replacement list
            Hash list
            Pointer to buffer
                                                                  Buffer
                                                                 Headers



                                                                 Buffers




     Granule

24 STOP 2005 Julian Dyke
     ©                                                  juliandyke.com
X$BH
         Externalises buffer headers
              ADDR           RAW(4)
                                        Hash List Address
              INDX           NUMBER
              INST_ID        NUMBER     Block Size
              HLADDR         RAW(4)
              BLSIZ          NUMBER     Hash List
              NXT_HASH       RAW(4)
                                        Replacement List
              PRV_HASH       RAW(4)
              NXT_REPL       RAW(4)     Tablespace#
              PRV_REPL       RAW(4)
                                        Absolute File Number
              TS#            NUMBER
              FILE#          NUMBER     Relative File Number
              DBARFIL        NUMBER     Block Number
              DBABLK         NUMBER
              OBJ            NUMBER     Object ID
              BA             RAW(4)     Buffer Address
              CR_SCN_BAS     NUMBER

25   © 2005 Julian Dyke                      juliandyke.com
Shared Pool
                       56400000   Shared Pool includes
                                     Permanent Area
                       56800000
                                     Segmented Arrays
                       56C00000      Library Cache
                       57000000      Row Cache
                                     Reserved Area
                       57400000


                       57800000   Shared Pool occupies
                                     8 x 4M granules = 32M
                       57C00000
                                     SHARED_POOL_SIZE = 20M
                       58000000



26 STOP 2005 Julian Dyke
     ©                                                   juliandyke.com
V$SGASTAT
         Describes sizes of individual components in SGA
                 SELECT pool, name, value FROM v$sgastat;

                  Pool           Name                  Value
                                 fixed sga            452044
                                 buffer cache       50331648
                                 log buffer           656384
                  shared pool    enqueues              51680
                  shared pool    sessions              91656
                  shared pool    library cache       1480240
                  shared pool    dictionary cache    1614976


                  shared pool    free memory        19746760
                  large pool     free memory        12582912
                  java pool      free memory        20971520

27   © 2005 Julian Dyke                               juliandyke.com
Permanent Areas
         Allocated at instance startup   56400000
         Contain structures such as
            processes                    56800000
            sessions
                                          56C00000
            segmented arrays

             SELECT ksmchptr, ksmchsiz    57000000
             FROM x$ksmsp
             WHERE ksmchcls = 'perm';
                                          57400000

               Address           Size
                                          57800000
               5641F000       3967868
               5681F000       2718736     57C00000
               56AB6C10        905116
               56C1F00        4063188     58000000
               5701F000       4067328


28 STOP 2005 Julian Dyke
     ©                                               juliandyke.com
Sessions
         Array of sessions stored in shared pool permanent area
         Allocated at instance startup
         Number of elements specified by SESSIONS parameter
         In Oracle 9.2 each element is 2412 bytes
         Session array externalised by
            X$KSUSE
                General information
                Used by V$SESSION
            X$KSUSESTA
                Statistics
                Used by V$SESSTAT
            X$KSUSECST
                Current Waits
                Used by V$SESSION_WAIT


29   © 2005 Julian Dyke                               juliandyke.com
Sessions
  ksusga_


struct ksusg




        Array of            X$KSUSE    X$KSUSESTA     X$KSUSECST
        Pointers           V$SESSION    V$SESSTAT   V$SESSION_WAIT


30 STOP 2005 Julian Dyke
     ©                                              juliandyke.com
Segmented Arrays
         Used to store arrays of objects
            Array too large to fit in granule
            Array may grow dynamically


         Objects using segmented arrays include
            enqueues (locks)
            enqueue resources (resources)
            transactions
            transaction branches


         Segmented arrays managed recursively by segmented array

         Segmented arrays externalised in X$KSMDD


31   © 2005 Julian Dyke                              juliandyke.com
Segmented Arrays
            Segmented              Call
              Arrays

                                              Segmented
                                                Array

           Segmented
                                 Enqueues
              Array  Segmented
             Header    Array




                    Segmented
                       Array      Enqueue
                      Header     Resources




32 STOP 2005 Julian Dyke
     ©                                       juliandyke.com
X$KSMDD
         Externalises segmented array headers   Name of array
             ADDR             RAW(4)
             INDX             NUMBER
             INST_ID          NUMBER
             NAME             VARCHAR2(30)
             ELEMENTS_CHUNK   NUMBER
             ITEMS_PT         NUMBER
             INITENTRIES      NUMBER
             NUMENTRIES       NUMBER             Number of
                                                 chunks
             CURENTRIES       NUMBER
             NUMCHUNKS        NUMBER
                                                 Address of parent
             ELEMSIZE         NUMBER             heap
             FLAGS            NUMBER
             HEAP             RAW(4)
             SECONDARY        RAW(4)

33   © 2005 Julian Dyke                              juliandyke.com
Heaps
         A heap consists of one or more extents
         Each heap extent occupies a single granule
         Each extent contains one or more chunks
         Each heap has a header containing
            list of used chunks
            list of free chunks

                 Heap       Extent 0     Extent 1      Extent 2
    Header



   Free List                                                      Chunks




34 STOP 2005 Julian Dyke
     ©                                                 juliandyke.com
Extent
      Chunks                                Extent
                                                     Header

         Chunks contain                             Chunk
            header                                  Header
            body
                                                      Chunk
                                                      Body
         Size of chunk header
          dependent on chunk type
            16 bytes <= size <= 32 bytes


         Chunks chained through extent

         Chunks can be
            permanent
            recreatable
            freeable
            free


35 STOP 2005 Julian Dyke
     ©                                         juliandyke.com
X$KSMSP
         Externalises chunks in the shared pool   Description of chunk type

                                                   Address of chunk
           ADDR            RAW(4)
                                                   Size including header
           INDX            NUMBER
           INST_ID         NUMBER                  Class
                                                   ●Perm
           KSMCHIDX        NUMBER                  ●Recreate
           KSMCHDUR        NUMBER                  ●Freeable
                                                   ●Free
           KSMCHCOM        VARCHAR2(16)            ●R-Free
           KSMCHPTR        RAW(4)                  ●R-Freeable

           KSMCHSIZ        NUMBER                  Type (recreate only)
                                                   ●0x18 - KGL Handle
           KSMCHCLS        VARCHAR2(8)             ●0x24 - Fixed Allocation
           KSMCHTYP        NUMBER                  ●0x74 - KQR PO
                                                   ●0x80 - KQR SO
           KSMCHPAR        RAW(4)                  ●0xFFF - Extended header

                                                   Address of parent



36   © 2005 Julian Dyke                                  juliandyke.com
Heap Dumps
         Heaps can be dumped using

              ALTER SESSION SET EVENTS
              ‘immediate trace name heapdump level <level>’;
         where <level> is

                  Heap                 Summary      Detail
                  PGA                        1       1025
                  SGA                        2       2050
                  UGA                        4       4100
                  CGA – Current Call         8       8200
                  CGA – User Call           16      16400
                  LGA – Large Pool          32      32800




37   © 2005 Julian Dyke                               juliandyke.com
Free List
         Heap free lists contain 255 buckets

         Each bucket contains double linked list to free chunks

         Bucket sizes increase in
            increments of 4 bytes - 16, 20, 24, 28, 32 ... 808, 812
            increments of 64 bytes - 876, 940, 1004 ... 3948, 4012
            then 4108, 8204, 16396, 32780, 65548


         Reduces fragmentation




38   © 2005 Julian Dyke                                   juliandyke.com
Free List
          Example

 Heap Header


                          16       24 byte chunks
                          20
 Buckets
                          24
                          28       36 byte chunks
                          32
                          36
                          40
                          44
                          48
                          52
                                   52 byte chunks
                          56
                          60
                          64


39   © 2005 Julian Dyke        juliandyke.com
Subheaps
         Heaps can contain subheaps
         Objects can have up to 10 subheaps
            SQL statements include subheaps 0 and 6


         Subheaps consist of one or more extents
         Subheaps have heap headers
            Subheap header format similar to heap header format
            Only one freelist containing all free space

                                   Extent 0   Extent 1     Extent 2
          Subheap
           Header




             Free
             List                                  Chunk


40   © 2005 Julian Dyke                                  juliandyke.com
Subheap Dumps
         In Oracle 9.0.1 and below to dump a subheap, first obtain the
          address of the subheap and convert to decimal
                              0x56b95c0c = 1454988300
         For a summary dump use
              ALTER SESSION SET EVENTS
              ‘immediate trace name heapdump_addr level 1454988300’;
         For a detailed dump add 1 to the address e.g.
              ALTER SESSION SET EVENTS
              ‘immediate trace name heapdump_addr level 1454988301’;

         In Oracle 9.2 and above to dump the subheap summary use
              ALTER SESSION SET EVENTS
              ‘immediate trace name heapdump_addr level 1, addr 0x56b95c0c’;
         For a detailed dump use
              ALTER SESSION SET EVENTS
              ‘immediate trace name heapdump_addr level 2, addr 0x56b95c0c’;


41   © 2005 Julian Dyke                                        juliandyke.com
Subheap Dumps
         Example - dump the SGA using
          ALTER SESSION SET EVENTS ‘immediate trace name heapdump level 2’;


     Chunk 56b94dc8   sz= 304   recreate   "KGL handles       "   latch=0x56efd918
     Chunk 56b94ef8   sz= 560   freeable   "library cache     "   ds=0x56b95c0c
     Chunk 56b95128   sz= 540   recreate   "KQR PO            "   latch=(nil)
     Chunk 56b95344   sz= 540   recreate   "KQR PO            "   latch=0x56d719f4
     Chunk 56b95560   sz=1116   freeable   "KGLS heap         "   ds=0x56b96d1c
     Chunk 56b959bc   sz= 20    free       "                  "
     Chunk 56b959d0   sz= 560   recreate   "library cache     "   latch=(nil)
        ds 56b95c0c   sz=1120   ct=          2
           56b94ef8   sz= 560
     Chunk 56b95c00   sz= 96    freeable   "library cache     "

         Dump subheap using
             ALTER SESSION SET EVENTS
             ‘immediate trace name heapdump_addr level 1, addr 0x56b95c0c’;



42   © 2005 Julian Dyke                                           juliandyke.com
Subheap Dumps
                 HEAP DUMP heap name="library cache" desc=0x576193c4
     Extent 0     extent sz=0x224 alt=32767 het=16 rec=9 flg=2 opc=2
                  parent=0x5000002c owner=0x5761826c nex=(nil) xsz=0x224
                 EXTENT 0 addr=0x57615130
                   Chunk 57615138 sz=      312    perm      "perm          "   alo=260
                   Chunk 57615270 sz=       76    freeable "kgltbtab       "
                   Chunk 576152bc sz=       76    freeable "kgltbtab       "
     Extent 1      Chunk 57615308 sz=       76    freeable "kgltbtab       "
                 EXTENT 1 addr=0x57616a88
                   Chunk 57616a90 sz=      512    perm      "perm          "   alo=512
     Extent 2      Chunk 57616c90 sz=       28    free      "              "
                 EXTENT 2 addr=0x57618254
                   Chunk 5761825c sz=      172    perm      "perm          "   alo=172
                   Chunk 57618308 sz=       36    free      "              "
     Free List   Total heap size    =     1288
                 FREE LISTS:
                  Bucket 0 size=0
                   Chunk 57616c90 sz=       28      free      "            "
                   Chunk 57618308 sz=       36      free      "            "
                 Total free space   =       64
                 UNPINNED RECREATABLE CHUNKS (lru   first):
                 PERMANENT CHUNKS:
                   Chunk 57615138 sz=      312      perm      "perm        "   alo=260
                   Chunk 57616a90 sz=      512      perm      "perm        "   alo=512
                   Chunk 5761825c sz=      172      perm      "perm        "   alo=172
                 Permanent space    =      996

43     © 2005 Julian Dyke                                             juliandyke.com
X$KSMHP
         Externalises chunks in a subheap

           ADDR           RAW(4)
           INDX           NUMBER             Address of data segment
           INST_ID        NUMBER
           KSMCHDS        RAW(4)             Description of chunk type

           KSMCHCOM       VARCHAR2(16)       Address of chunk
           KSMCHPTR       RAW(4)
           KSMCHSIZ       NUMBER             Size including header

           KSMCHCLS       VARCHAR2(8)        Class
           KSMCHTYP       NUMBER             ●Perm
                                             ●Free
           KSMCHPAR       RAW(4)
           KSMCHOWN       RAW(4)             Address of parent heap




44   © 2005 Julian Dyke                              juliandyke.com
X$KSMHP
                 SQL> SELECT COUNT(*) FROM x$ksmhp;
                 COUNT(*)
                 --------
                   SQL> SELECT COUNT(*) FROM
                        0
                   x$ksmhp;
                   0 rows
                 SQL> SELECT kglobhd6 FROM x$kglob
                 WHERE kglnaobj = 'SELECT SUM(c1) FROM t1'
                 AND kglhdadr != kglhdpar;
                 KGLOBHD6
                 --------
                 5755E798

                 SQL> SELECT COUNT(*) FROM x$ksmhp
                 WHERE ksmchds = HEXTORAW ('5755E798');
                 COUNT(*)
                 --------
                        1

45 STOP 2005 Julian Dyke
     ©                                           juliandyke.com
Library Cache
         Database objects
            Tables
            Views
            Packages
            Functions


         Shared cursors
            SQL statements
            Anonymous PL/SQL block
            Stored PL/SQL procedures and functions
            Java stored procedures
            Methods




46   © 2005 Julian Dyke                               juliandyke.com
Library Cache
         For example
                             CREATE TABLE t1
                             (
                                c1 NUMBER,
                                c2 NUMBER,
                                c3 NUMBER,
                                c4 NUMBER
                             );
                             CREATE INDEX i1 ON t1 (c1);
                             CREATE INDEX i2 ON t1 (c3);

                                  SELECT SUM(c2)
                                  FROM t1
                                  WHERE c3 = 42
                                  AND c4 < 2004;

            0       SELECT STATEMENT
            1   0     SORT (AGGREGATE)
            2   1       TABLE ACCESS (BY INDEX ROWID) OF 'T1'
            3   2         INDEX (RANGE SCAN) OF 'I2'


47 STOP 2005 Julian Dyke
     ©                                                      juliandyke.com
Library Cache                  512 x 1 word
                                       pointers
                                                                Library Cache
                                                                Object Handle

                                                    256 x DLL
                            Heap                     headers
      ksmgsg_                                                         KGLHD

                           Library
    struct kgsms           Cache
                                                                      KGLHD


                                                                      KGLHD


                                                                      KGLHD


                                                      512 x 256 =
                                                    131072 buckets
     Anonymous
        List
                           KGLHD     KGLHD           KGLHD           KGLHD



48 STOP 2005 Julian Dyke
     ©                                                     juliandyke.com
Library Cache Object - Parent
             KGLHD                   KGLNA                  Parent
                           SELECT SUM (c2) FROM t1          Name
                           WHERE c3 = 42 AND c4 < 2004


                           KGLOB             Parent
                                             Object
                                                            Heap 0
              Parent
              Handle                            X$KGLOB     Child
                                                           Handle

                                                            KGLHD
                                             Child 1


             16 x 1 word                                    KGLHD
              pointers                       Child 2




49 STOP 2005 Julian Dyke
     ©                                                    juliandyke.com
Library Cache Object - Child
                           Child                  Statistics
                           Object      Subheap
             KGLHD                                   etc
                                        Header


                           KGLOB

                                       Heap 0




               Child                   Heap 6
              Handle                              Subquery
                                                   Header


                             X$KGLOB   Subheap
                                        Header     SELECT
                                                  Statement




50 STOP 2005 Julian Dyke
     ©                                           juliandyke.com
Library Cache - Statement
                           Subquery
                            Header




         Explain                          SORT
          Plan             Operation
                                       (AGGREGATE)



         Explain
          Plan             Operation TABLE ACCESS (BY
                                       INDEX ROWID)



         Explain                           INDEX
          Plan             Operation
                                       (RANGE SCAN)



51 STOP 2005 Julian Dyke
     ©                                                  juliandyke.com
Sort (Aggregate)
               Output             SORT (AGGREGATE)
              Columns

                                       Expression

                                   Function Expression
                                        Op=SUM

                                       Expression

                                   Column Expression

                                         Variable


                           Column Definition   Column Alias
                              Obj =1234          Alias=C2
                                Col=2



52 STOP 2005 Julian Dyke
     ©                                                        juliandyke.com
Table Access (By Index Rowid)
     Output                                                                    Predicate
    Columns             TABLE ACCESS (BY INDEX ROWID)
                                                                               c4 < 2004
                                             ROWID
               Variable         Expression Expression           Condition

         Column Definition    Column Expression                Expression
            Obj =1234
              Col=2
                               Variable                   Function Expression
                                                                 Op=LT

                Column Definition    Table Alias     Expression       Expression
                   Obj =1234          Alias=T1
                   Col=ROWID
                                            Column Expression        Constant Expression

                                                   Variable                   Constant
                                                                             Value=2004

                                      Column Definition       Column Alias
                                         Obj =1234              Alias=C4
                                           Col=4
53 STOP 2005 Julian Dyke
     ©                                                              juliandyke.com
Index (Range Scan)
          Output                                                           Predicate
         Columns                      INDEX (RANGE SCAN)                    c3 = 42

                           Variable                  Expression Array

                     Column Definition                    Expression
                        Obj =1234
                        Col=ROWID
                                                    Function Expression
                                                          Op=EQ

                                               Expression        Expression

                                        Column Expression       Constant Expression

                                              Variable                  Constant
                                                                        Value=42

                                Column Definition        Column Alias
                                   Obj =1234               Alias=C3
                                     Col=3
54 STOP 2005 Julian Dyke
     ©                                                                  juliandyke.com
Shared Pool Reserved Area
         Area of memory reserved for large contiguous requests for
          memory
         Reduces fragmentation in shared pool
         Only used if no space available in shared pool
         Summarised in V$SHARED_POOL_RESERVED

             SHARED_POOL_RESERVED_SIZE
                specifies size of shared pool in bytes
                defaults to 5% of SHARED_POOL_SIZE


             _SHARED_POOL_RESERVED_PCT
                specifies percentage of shared pool to reserve
                defaults to 5%


             _SHARED_POOL_RESERVED_MIN_ALLOC
                specifies minimum chunk size e.g. 4400

55   © 2005 Julian Dyke                                   juliandyke.com
X$KSMSPR
         Externalises address, size and class of all chunks in the
          shared pool                                 Comment
                                                     ● free memory
             ADDR            RAW(4)                  ● reserved_stopper
             INDX            NUMBER
             INST_ID         NUMBER                  Address
             KSMCHCOM        VARCHAR2(16)
             KSMCHPTR        RAW(4)                  Size in bytes
             KSMCHSIZ        NUMBER
             KSMCHCLS        VARCHAR2(8)             Class
                                                     ●R-free
             KSMCHTYP        NUMBER                  ●R-freeable
             KSMCHPAR        RAW(4)




56   © 2005 Julian Dyke                                  juliandyke.com
Shared Pool Reserved Area
                                                        56400000
       SELECT ksmchcom,ksmchptr,ksmchsiz,ksmchcls

       FROM x$ksmspr                                    56800000
       ORDER BY ksmchptr;

                                                        56C00000
   KSMCHCOM            KSMCHPTR   KSMCHSIZ KSMCHCLS
   reserved_stopper    56400024         20 R-freeable   57000000
   free memory         56400038     126900 R-free
   reserved_stopper    5641EFEC         20 R-freeable   57400000
   reserved_stopper    56800024         20 R-freeable
   free memory         56800038     126900 R-free       57800000
   reserved_stopper    5681EFEC         20 R-freeable
   reserved_stopper    56C00024         20 R-freeable   57C00000

   free memory         56C00038     126900 R-free
                                                        58000000
   reserved_stopper    56C1EFEC         20 R-freeable
   reserved_stopper    57000024         20 R-freeable

57 STOP 2005 Julian Dyke
     ©                                                   juliandyke.com
Log Buffer
                    58400000       Guard Page

                                         LOG_BUFFER = 524288
                                  2 x 4K guard pages (DEADFACE)
                                  1288 x 512 byte blocks for redo
                                  Each 512 byte includes 16 byte header
                                  Usable redo = 1288 x 496 = 638848 bytes
                                                 Header - 16 bytes


                                                 Body - 496 bytes


                    584A2000
                                   Guard Page

58 STOP 2005 Julian Dyke
     ©                                                     juliandyke.com
Thank you for your interest

       For more information and to provide feedback

       please contact me
       My e-mail address is:
                   info@juliandyke.com

       My website address is:

                          www.juliandyke.com




59   © 2005 Julian Dyke                        juliandyke.com

Weitere ähnliche Inhalte

Was ist angesagt?

Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by exampleMauro Pagano
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS processRiyaj Shamsudeen
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04Carlos Sierra
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionMarkus Michalewicz
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesTanel Poder
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWRpasalapudi
 
Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsAnil Nair
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slidesMohamed Farouk
 
Oracle RAC features on Exadata
Oracle RAC features on ExadataOracle RAC features on Exadata
Oracle RAC features on ExadataAnil Nair
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsEnkitec
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuningAiougVizagChapter
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsCarlos Sierra
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Oracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONOracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONMarkus Michalewicz
 
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019Sandesh Rao
 
Why oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cWhy oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cSatishbabu Gunukula
 

Was ist angesagt? (20)

Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS process
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion Edition
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling Examples
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWR
 
Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret Internals
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slides
 
Oracle RAC features on Exadata
Oracle RAC features on ExadataOracle RAC features on Exadata
Oracle RAC features on Exadata
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuning
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Oracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONOracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLON
 
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
 
Why oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cWhy oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19c
 

Ähnlich wie Understanding Oracle SGA Internals

2713897 oracle-unix-oracle
2713897 oracle-unix-oracle2713897 oracle-unix-oracle
2713897 oracle-unix-oraclesivacse09
 
Ora01_OraArc.pdf
Ora01_OraArc.pdfOra01_OraArc.pdf
Ora01_OraArc.pdfNamNguynMu
 
Using The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamUsing The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamLuís Soares
 
3 storage innovations for improving performance, efficiency, and manageability
3 storage innovations for improving performance, efficiency, and manageability3 storage innovations for improving performance, efficiency, and manageability
3 storage innovations for improving performance, efficiency, and manageabilityDr. Wilfred Lin (Ph.D.)
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...Frederic Descamps
 
Huawei Symantec Oceanspace VTL6000 Overview
Huawei Symantec Oceanspace VTL6000 OverviewHuawei Symantec Oceanspace VTL6000 Overview
Huawei Symantec Oceanspace VTL6000 OverviewUtopia Media
 
Meetup my sql5.6_cluster
Meetup my sql5.6_clusterMeetup my sql5.6_cluster
Meetup my sql5.6_clusterLee Stigile
 
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By Presentation
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By PresentationRemote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By Presentation
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By PresentationRemote DBA Services
 
SUN+Oracle存储产品介绍
SUN+Oracle存储产品介绍SUN+Oracle存储产品介绍
SUN+Oracle存储产品介绍PencilData
 
EMC Multisite DR for SQL Server 2012
EMC Multisite DR for SQL Server 2012EMC Multisite DR for SQL Server 2012
EMC Multisite DR for SQL Server 2012xKinAnx
 
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdf
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdfOracle Database 11g SQL Tuning Workshop - Student Guide.pdf
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdfRajendra Jain
 
Using next gen storage in Cloudstack
Using next gen storage in CloudstackUsing next gen storage in Cloudstack
Using next gen storage in CloudstackShapeBlue
 
Homework help on oracle
Homework help on oracleHomework help on oracle
Homework help on oracleSteve Nash
 
Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006Sal Marcus
 
Presentation oracle super cluster t5-8 technical deep dive
Presentation   oracle super cluster t5-8 technical deep divePresentation   oracle super cluster t5-8 technical deep dive
Presentation oracle super cluster t5-8 technical deep divesolarisyougood
 
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBaseHBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBaseHBaseCon
 

Ähnlich wie Understanding Oracle SGA Internals (20)

Inside rac
Inside racInside rac
Inside rac
 
2713897 oracle-unix-oracle
2713897 oracle-unix-oracle2713897 oracle-unix-oracle
2713897 oracle-unix-oracle
 
Ora01_OraArc.pdf
Ora01_OraArc.pdfOra01_OraArc.pdf
Ora01_OraArc.pdf
 
Using The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamUsing The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change Stream
 
3 storage innovations for improving performance, efficiency, and manageability
3 storage innovations for improving performance, efficiency, and manageability3 storage innovations for improving performance, efficiency, and manageability
3 storage innovations for improving performance, efficiency, and manageability
 
Session 307 ravi pendekanti engineered systems
Session 307  ravi pendekanti engineered systemsSession 307  ravi pendekanti engineered systems
Session 307 ravi pendekanti engineered systems
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
Huawei Symantec Oceanspace VTL6000 Overview
Huawei Symantec Oceanspace VTL6000 OverviewHuawei Symantec Oceanspace VTL6000 Overview
Huawei Symantec Oceanspace VTL6000 Overview
 
Les 13 memory
Les 13 memoryLes 13 memory
Les 13 memory
 
Meetup my sql5.6_cluster
Meetup my sql5.6_clusterMeetup my sql5.6_cluster
Meetup my sql5.6_cluster
 
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By Presentation
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By PresentationRemote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By Presentation
Remote DBA team-1Z0-042 Oracle Sga In Nutshell Oracle Dba Learn By Presentation
 
11g R2
11g R211g R2
11g R2
 
SUN+Oracle存储产品介绍
SUN+Oracle存储产品介绍SUN+Oracle存储产品介绍
SUN+Oracle存储产品介绍
 
EMC Multisite DR for SQL Server 2012
EMC Multisite DR for SQL Server 2012EMC Multisite DR for SQL Server 2012
EMC Multisite DR for SQL Server 2012
 
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdf
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdfOracle Database 11g SQL Tuning Workshop - Student Guide.pdf
Oracle Database 11g SQL Tuning Workshop - Student Guide.pdf
 
Using next gen storage in Cloudstack
Using next gen storage in CloudstackUsing next gen storage in Cloudstack
Using next gen storage in Cloudstack
 
Homework help on oracle
Homework help on oracleHomework help on oracle
Homework help on oracle
 
Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006
 
Presentation oracle super cluster t5-8 technical deep dive
Presentation   oracle super cluster t5-8 technical deep divePresentation   oracle super cluster t5-8 technical deep dive
Presentation oracle super cluster t5-8 technical deep dive
 
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBaseHBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
 

Kürzlich hochgeladen

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Kürzlich hochgeladen (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Understanding Oracle SGA Internals

  • 1. SGA Internals Julian Dyke Independent Consultant Web Version 1 © 2005 Julian Dyke juliandyke.com
  • 2. Agenda  Introduction  SGA  Granules  Fixed SGA  Buffer Cache  Shared Pool  Permanent Areas  Heaps  Subheaps  Library Cache  Reserved Area  Log Buffer  Conclusion 2 © 2005 Julian Dyke juliandyke.com
  • 3. Introduction  Examples based on  32 bit architecture  Red Hat 2.1 AS  Oracle 9.2.0.4  Single (non-RAC) instance  Examples affected by  Oracle version  Operating system  Single instance / RAC  Architecture (32/64)  Parameters 3 © 2005 Julian Dyke juliandyke.com
  • 4. Word Length  Word length can be  32 bit - 4 byte pointers  64 bit - 8 byte pointers  Also affects  size of some integer variables e.g. int  word alignment  When moving from 32 bit to 64 bit Oracle recommends doubling  SHARED_POOL_SIZE  SHARED_POOL_RESERVED_SIZE  LARGE_POOL_SIZE 4 © 2005 Julian Dyke juliandyke.com
  • 5. Double Linked Lists - Insertion  Frequently used in SGA structures  Each element includes pointers to next and previous elements  Requires 8 bytes (32 bit systems) or 16 bytes (64 bit systems) 5000F430 55443080 55845C54 52175AC0 Head 5000F430 Tail 5000F430 5 © 2005 Julian Dyke STOP juliandyke.com
  • 6. Double Linked Lists - Deletion  Double linked lists are more efficient for  insertion  deletion 5000F430 55443080 55845C54 52175AC0 Head 55443080 55845C54 52175AC0 5000F430 Tail 52175AC0 5000F430 55443080 55845C54 6 © 2005 Julian Dyke STOP juliandyke.com
  • 7. Memory Areas 08048000  An Oracle process includes Executable the following memory areas 0AAA28C0 PGA Session Heap  Executable  PGA/Session Heap Shared 40000000 Libraries  Shared Libraries  SGA 50000000  Stack SGA 584A4000 Stack 7 © 2005 Julian Dyke STOP juliandyke.com
  • 8. Shared Memory  Shared memory can be dumped to trace file using $ sqlplus /nolog SQL> CONNECT SYS/<password> AS SYSDBA Connected SQL> ORADEBUG SETMYPID ORADEBUG SETMYPID Statement processed ORADEBUG IPC SQL> ORADEBUG IPC Information written to trace file SQL> ORADEBUG TRACEFILE_NAME /var/opt/oracle/admin/LX092001/udump/lx092001_ora_9824.trc 8 © 2005 Julian Dyke juliandyke.com
  • 9. ORADEBUG IPC - Example Area #0 `Fixed Size' containing Subareas 0-0 Total size 000000000006e5cc Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 0 0 163840 0x00000050000000 0x00000050000000 Fixed Area Subarea size Segment size 000000000006f000 0000000008800000 Area #1 `Variable Size' containing Subareas 1-1 Total size 0000000008000000 Minimum Subarea size 00400000 Area Subarea Shmid Stable Addr Actual Addr Variable Area 1 1 163840 0x0000005006f000 0x0000005006f000 Subarea size Segment size 0000000008391000 0000000008800000 Area #2 `Redo Buffers' containing Subareas 2-2 Total size 00000000000a3000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 2 2 163840 0x00000058400000 0x00000058400000 Redo Buffers Subarea size Segment size 00000000000a3000 0000000008800000 Area #3 `skgm overhead' containing Subareas 3-3 Total size 0000000000001000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 3 3 163840 0x000000584a3000 0x000000584a3000 OS Specific Subarea size Segment size 0000000000001000 0000000008800000 9 © 2005 Julian Dyke STOP juliandyke.com
  • 10. V$SGA  Describes sizes of main components in SGA  Used by SHOW SGA command in SQL*Plus SELECT name, value FROM v$sga; Name Value Fixed Size 452044 Variable Size 83886080 Database Buffers 50331648 Redo Buffers 667648  Based from X$KSMSD  X$KSMSD derived from ksmstv_ (ksmst) in Fixed SGA 10 © 2005 Julian Dyke juliandyke.com
  • 11. Shared Global Area  Contains  Fixed SGA  Buffer Pool  Shared Pool Oracle 7.0 and above  Large Pool Oracle 8.0 and above  Java Pool Oracle 8.1.5 and above  Streams Pool Oracle 10.1 and above  Redo buffers  Buffer Pool includes  Default cache  Keep and Recycle cache Oracle 8.0 and above  2K, 4K, 8K, 16K and 32K cache Oracle 9.0.1 and above 11 © 2005 Julian Dyke juliandyke.com
  • 12. Granules  Introduced in Oracle 9.0.1  SGA divided into granules  In Oracle 9.2 granule size dependent on SGA_MAX_SIZE  4 mb SGA_MAX_SIZE <= 128 mb  16 mb SGA_MAX_SIZE > 128 mb  If SGA_MAX_SIZE not set explicitly then defaults to sum of individual pool parameters  SGA_MAX_SIZE cannot be dynamically modified 12 © 2005 Julian Dyke juliandyke.com
  • 13. Granules  Pool parameters rounded up to nearest granule  Each pool occupies one or more granules  Different buffer caches held in separate granules  First "granule" contains  Fixed SGA  Granule directory  Heap headers  Last "granule" contains  Guard pages  Redo buffer  Operating system specific overhead  Remaining space unused 13 © 2005 Julian Dyke juliandyke.com
  • 14. Granules SGA_MAX_SIZE = 128M 4M Fixed SGA 4M DB_CACHE_SIZE = 48M Free 16M JAVA_POOL_SIZE = 20M LARGE_POOL_SIZE = 12M Buffer Pool 48M SHARED_POOL_SIZE = 20M 128M Java Pool 20M Large Pool 12M Shared Pool 32M Note – shared pool size automatically increased Redo Buffer 4M from 20M to 32M 4M 14 STOP 2005 Julian Dyke © juliandyke.com
  • 15. Granule Operations  The following pools can be dynamically resized Pool Parameter Version Shared Pool SHARED_POOL_SIZE 9.0.1 and above Default DB_CACHE_SIZE 9.0.1 and above 2K DB_2K_CACHE_SIZE 9.0.1 and above 4K DB_4K_CACHE_SIZE 9.0.1 and above 8K DB_8K_CACHE_SIZE 9.0.1 and above 16K DB_16K_CACHE_SIZE 9.0.1 and above 32K DB_32K_CACHE_SIZE 9.0.1 and above Keep DB_KEEP_CACHE_SIZE 9.0.1 and above Recycle DB_RECYCLE_CACHE_SIZE 9.0.1 and above Large Pool LARGE_POOL_SIZE 9.2.0 and above Java Pool JAVA_POOL_SIZE 10.1 and above  Streams pool cannot be dynamically resized in Oracle 10.1 15 © 2005 Julian Dyke juliandyke.com
  • 16. Granule Views  The following views support dynamic memory management  Introduced in Oracle 9.2  V$SGA_DYNAMIC_COMPONENTS  V$SGA_DYNAMIC_FREE_MEMORY  V$SGA_CURRENT_RESIZE_OPS  V$SGA_RESIZE_OPS  Not always reliable  Introduced in Oracle 10.1  V$SGAINFO 16 © 2005 Julian Dyke juliandyke.com
  • 17. X$KSMGE Introduced in Oracle 9.2 Describes individual granules Granule ID ADDR RAW(4) 0 Free 2 Shared Pool INDX NUMBER 3 Large Pool INST_ID NUMBER 4 Java Pool 5 Buffer Pool GRANNUM NUMBER GRANTYPE NUMBER INVALID (Free) ALLOCATED GRANSTATE VARCHAR2(16) GRANFLAGS NUMBER Granule Address LOCALITY NUMBER Granule Size BASEADDR RAW(4) GRANSIZE NUMBER Next granule ID GRANNEXT NUMBER Previous granule ID GRANPREV NUMBER 17 © 2005 Julian Dyke juliandyke.com
  • 18. Granule Dumps  Granules can be dumped using ALTER SESSION SET EVENTS ‘immediate trace name granulelist level <level>’  where <level> is Heap Level Null Granule 255 Home Granule 511 Shared Pool 767 Large Pool 1023 Java Pool 1279 Buffer Cache 1535 18 © 2005 Julian Dyke juliandyke.com
  • 19. Fixed SGA  Area containing all fixed variables  Contains pointers to all other structures in SGA  Variable name, type, address and size determined when Oracle executable is linked  Located at start of first granule of SGA 50000000 Fixed SGA 5001D9E8 Granule Directory 5001DF50 Heap Headers 19 STOP 2005 Julian Dyke © juliandyke.com
  • 20. X$KSMFSV  Externalises name, type, address and size of all variables in fixed SGA Name ADDR RAW(4) INDX NUMBER Type INST_ID NUMBER Address KSMFSNAM VARCHAR2(64) KSMFSTYP VARCHAR2(64) Size KSMFSADR RAW(4) KSMFSSIZ NUMBER  SGA can be dumped using ORADEBUG FIXEDSGA 20 © 2005 Julian Dyke juliandyke.com
  • 21. Global Area Dumps  Global areas can be dumped using ALTER SESSION SET EVENTS ‘immediate trace name global_area level <level>’  where <level> is Heap Level PGA 1 SGA 2 PGA + SGA 3 UGA 4 PGA + UGA 5 SGA + UGA 6 PGA + SGA + UGA 7  More detail is included at levels 0x08 0x10 0x18 (OR) 21 © 2005 Julian Dyke juliandyke.com
  • 22. X$KSMMEM  Externalises contents of all locations in the SGA Address ADDR RAW(4) INDX NUMBER INST_ID NUMBER Value KSMMMVAL RAW(4)  Does not work on Windows platforms 22 © 2005 Julian Dyke juliandyke.com
  • 23. Buffer Cache 51400000 DB_CACHE_SIZE = 48M 51800000 DB_BLOCK_SIZE = 8192 51C00000  Buffer Cache includes 12 x 4M granules 52000000  Each granule contains 500 buffers 52400000  Buffer Cache contains 6000 buffers 52800000 Block Buffers Per 52C00000 Size Granule 53000000 4mb 16mb 53400000 53800000 2048 1875 7503 4096 979 3916 53C00000 8192 500 2002 54000000 16384 253 1012 32768 127 509 23 © 2005 Julian Dyke STOP juliandyke.com
  • 24. Buffer Headers  Each buffer has a buffer header  In 9.2.0.4 buffer headers are 188 bytes  Buffer headers are stored in same granule as buffers  Buffer headers include  Replacement list  Hash list  Pointer to buffer Buffer Headers Buffers Granule 24 STOP 2005 Julian Dyke © juliandyke.com
  • 25. X$BH  Externalises buffer headers ADDR RAW(4) Hash List Address INDX NUMBER INST_ID NUMBER Block Size HLADDR RAW(4) BLSIZ NUMBER Hash List NXT_HASH RAW(4) Replacement List PRV_HASH RAW(4) NXT_REPL RAW(4) Tablespace# PRV_REPL RAW(4) Absolute File Number TS# NUMBER FILE# NUMBER Relative File Number DBARFIL NUMBER Block Number DBABLK NUMBER OBJ NUMBER Object ID BA RAW(4) Buffer Address CR_SCN_BAS NUMBER 25 © 2005 Julian Dyke juliandyke.com
  • 26. Shared Pool 56400000 Shared Pool includes  Permanent Area 56800000  Segmented Arrays 56C00000  Library Cache 57000000  Row Cache  Reserved Area 57400000 57800000 Shared Pool occupies  8 x 4M granules = 32M 57C00000  SHARED_POOL_SIZE = 20M 58000000 26 STOP 2005 Julian Dyke © juliandyke.com
  • 27. V$SGASTAT  Describes sizes of individual components in SGA SELECT pool, name, value FROM v$sgastat; Pool Name Value fixed sga 452044 buffer cache 50331648 log buffer 656384 shared pool enqueues 51680 shared pool sessions 91656 shared pool library cache 1480240 shared pool dictionary cache 1614976 shared pool free memory 19746760 large pool free memory 12582912 java pool free memory 20971520 27 © 2005 Julian Dyke juliandyke.com
  • 28. Permanent Areas  Allocated at instance startup 56400000  Contain structures such as  processes 56800000  sessions 56C00000  segmented arrays SELECT ksmchptr, ksmchsiz 57000000 FROM x$ksmsp WHERE ksmchcls = 'perm'; 57400000 Address Size 57800000 5641F000 3967868 5681F000 2718736 57C00000 56AB6C10 905116 56C1F00 4063188 58000000 5701F000 4067328 28 STOP 2005 Julian Dyke © juliandyke.com
  • 29. Sessions  Array of sessions stored in shared pool permanent area  Allocated at instance startup  Number of elements specified by SESSIONS parameter  In Oracle 9.2 each element is 2412 bytes  Session array externalised by  X$KSUSE  General information  Used by V$SESSION  X$KSUSESTA  Statistics  Used by V$SESSTAT  X$KSUSECST  Current Waits  Used by V$SESSION_WAIT 29 © 2005 Julian Dyke juliandyke.com
  • 30. Sessions ksusga_ struct ksusg Array of X$KSUSE X$KSUSESTA X$KSUSECST Pointers V$SESSION V$SESSTAT V$SESSION_WAIT 30 STOP 2005 Julian Dyke © juliandyke.com
  • 31. Segmented Arrays  Used to store arrays of objects  Array too large to fit in granule  Array may grow dynamically  Objects using segmented arrays include  enqueues (locks)  enqueue resources (resources)  transactions  transaction branches  Segmented arrays managed recursively by segmented array  Segmented arrays externalised in X$KSMDD 31 © 2005 Julian Dyke juliandyke.com
  • 32. Segmented Arrays Segmented Call Arrays Segmented Array Segmented Enqueues Array Segmented Header Array Segmented Array Enqueue Header Resources 32 STOP 2005 Julian Dyke © juliandyke.com
  • 33. X$KSMDD  Externalises segmented array headers Name of array ADDR RAW(4) INDX NUMBER INST_ID NUMBER NAME VARCHAR2(30) ELEMENTS_CHUNK NUMBER ITEMS_PT NUMBER INITENTRIES NUMBER NUMENTRIES NUMBER Number of chunks CURENTRIES NUMBER NUMCHUNKS NUMBER Address of parent ELEMSIZE NUMBER heap FLAGS NUMBER HEAP RAW(4) SECONDARY RAW(4) 33 © 2005 Julian Dyke juliandyke.com
  • 34. Heaps  A heap consists of one or more extents  Each heap extent occupies a single granule  Each extent contains one or more chunks  Each heap has a header containing  list of used chunks  list of free chunks Heap Extent 0 Extent 1 Extent 2 Header Free List Chunks 34 STOP 2005 Julian Dyke © juliandyke.com
  • 35. Extent Chunks Extent Header  Chunks contain Chunk  header Header  body Chunk Body  Size of chunk header dependent on chunk type  16 bytes <= size <= 32 bytes  Chunks chained through extent  Chunks can be  permanent  recreatable  freeable  free 35 STOP 2005 Julian Dyke © juliandyke.com
  • 36. X$KSMSP  Externalises chunks in the shared pool Description of chunk type Address of chunk ADDR RAW(4) Size including header INDX NUMBER INST_ID NUMBER Class ●Perm KSMCHIDX NUMBER ●Recreate KSMCHDUR NUMBER ●Freeable ●Free KSMCHCOM VARCHAR2(16) ●R-Free KSMCHPTR RAW(4) ●R-Freeable KSMCHSIZ NUMBER Type (recreate only) ●0x18 - KGL Handle KSMCHCLS VARCHAR2(8) ●0x24 - Fixed Allocation KSMCHTYP NUMBER ●0x74 - KQR PO ●0x80 - KQR SO KSMCHPAR RAW(4) ●0xFFF - Extended header Address of parent 36 © 2005 Julian Dyke juliandyke.com
  • 37. Heap Dumps  Heaps can be dumped using ALTER SESSION SET EVENTS ‘immediate trace name heapdump level <level>’;  where <level> is Heap Summary Detail PGA 1 1025 SGA 2 2050 UGA 4 4100 CGA – Current Call 8 8200 CGA – User Call 16 16400 LGA – Large Pool 32 32800 37 © 2005 Julian Dyke juliandyke.com
  • 38. Free List  Heap free lists contain 255 buckets  Each bucket contains double linked list to free chunks  Bucket sizes increase in  increments of 4 bytes - 16, 20, 24, 28, 32 ... 808, 812  increments of 64 bytes - 876, 940, 1004 ... 3948, 4012  then 4108, 8204, 16396, 32780, 65548  Reduces fragmentation 38 © 2005 Julian Dyke juliandyke.com
  • 39. Free List  Example Heap Header 16 24 byte chunks 20 Buckets 24 28 36 byte chunks 32 36 40 44 48 52 52 byte chunks 56 60 64 39 © 2005 Julian Dyke juliandyke.com
  • 40. Subheaps  Heaps can contain subheaps  Objects can have up to 10 subheaps  SQL statements include subheaps 0 and 6  Subheaps consist of one or more extents  Subheaps have heap headers  Subheap header format similar to heap header format  Only one freelist containing all free space Extent 0 Extent 1 Extent 2 Subheap Header Free List Chunk 40 © 2005 Julian Dyke juliandyke.com
  • 41. Subheap Dumps  In Oracle 9.0.1 and below to dump a subheap, first obtain the address of the subheap and convert to decimal 0x56b95c0c = 1454988300  For a summary dump use ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 1454988300’;  For a detailed dump add 1 to the address e.g. ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 1454988301’;  In Oracle 9.2 and above to dump the subheap summary use ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 1, addr 0x56b95c0c’;  For a detailed dump use ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 2, addr 0x56b95c0c’; 41 © 2005 Julian Dyke juliandyke.com
  • 42. Subheap Dumps  Example - dump the SGA using ALTER SESSION SET EVENTS ‘immediate trace name heapdump level 2’; Chunk 56b94dc8 sz= 304 recreate "KGL handles " latch=0x56efd918 Chunk 56b94ef8 sz= 560 freeable "library cache " ds=0x56b95c0c Chunk 56b95128 sz= 540 recreate "KQR PO " latch=(nil) Chunk 56b95344 sz= 540 recreate "KQR PO " latch=0x56d719f4 Chunk 56b95560 sz=1116 freeable "KGLS heap " ds=0x56b96d1c Chunk 56b959bc sz= 20 free " " Chunk 56b959d0 sz= 560 recreate "library cache " latch=(nil) ds 56b95c0c sz=1120 ct= 2 56b94ef8 sz= 560 Chunk 56b95c00 sz= 96 freeable "library cache "  Dump subheap using ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 1, addr 0x56b95c0c’; 42 © 2005 Julian Dyke juliandyke.com
  • 43. Subheap Dumps HEAP DUMP heap name="library cache" desc=0x576193c4 Extent 0 extent sz=0x224 alt=32767 het=16 rec=9 flg=2 opc=2 parent=0x5000002c owner=0x5761826c nex=(nil) xsz=0x224 EXTENT 0 addr=0x57615130 Chunk 57615138 sz= 312 perm "perm " alo=260 Chunk 57615270 sz= 76 freeable "kgltbtab " Chunk 576152bc sz= 76 freeable "kgltbtab " Extent 1 Chunk 57615308 sz= 76 freeable "kgltbtab " EXTENT 1 addr=0x57616a88 Chunk 57616a90 sz= 512 perm "perm " alo=512 Extent 2 Chunk 57616c90 sz= 28 free " " EXTENT 2 addr=0x57618254 Chunk 5761825c sz= 172 perm "perm " alo=172 Chunk 57618308 sz= 36 free " " Free List Total heap size = 1288 FREE LISTS: Bucket 0 size=0 Chunk 57616c90 sz= 28 free " " Chunk 57618308 sz= 36 free " " Total free space = 64 UNPINNED RECREATABLE CHUNKS (lru first): PERMANENT CHUNKS: Chunk 57615138 sz= 312 perm "perm " alo=260 Chunk 57616a90 sz= 512 perm "perm " alo=512 Chunk 5761825c sz= 172 perm "perm " alo=172 Permanent space = 996 43 © 2005 Julian Dyke juliandyke.com
  • 44. X$KSMHP  Externalises chunks in a subheap ADDR RAW(4) INDX NUMBER Address of data segment INST_ID NUMBER KSMCHDS RAW(4) Description of chunk type KSMCHCOM VARCHAR2(16) Address of chunk KSMCHPTR RAW(4) KSMCHSIZ NUMBER Size including header KSMCHCLS VARCHAR2(8) Class KSMCHTYP NUMBER ●Perm ●Free KSMCHPAR RAW(4) KSMCHOWN RAW(4) Address of parent heap 44 © 2005 Julian Dyke juliandyke.com
  • 45. X$KSMHP SQL> SELECT COUNT(*) FROM x$ksmhp; COUNT(*) -------- SQL> SELECT COUNT(*) FROM 0 x$ksmhp; 0 rows SQL> SELECT kglobhd6 FROM x$kglob WHERE kglnaobj = 'SELECT SUM(c1) FROM t1' AND kglhdadr != kglhdpar; KGLOBHD6 -------- 5755E798 SQL> SELECT COUNT(*) FROM x$ksmhp WHERE ksmchds = HEXTORAW ('5755E798'); COUNT(*) -------- 1 45 STOP 2005 Julian Dyke © juliandyke.com
  • 46. Library Cache  Database objects  Tables  Views  Packages  Functions  Shared cursors  SQL statements  Anonymous PL/SQL block  Stored PL/SQL procedures and functions  Java stored procedures  Methods 46 © 2005 Julian Dyke juliandyke.com
  • 47. Library Cache  For example CREATE TABLE t1 ( c1 NUMBER, c2 NUMBER, c3 NUMBER, c4 NUMBER ); CREATE INDEX i1 ON t1 (c1); CREATE INDEX i2 ON t1 (c3); SELECT SUM(c2) FROM t1 WHERE c3 = 42 AND c4 < 2004; 0 SELECT STATEMENT 1 0 SORT (AGGREGATE) 2 1 TABLE ACCESS (BY INDEX ROWID) OF 'T1' 3 2 INDEX (RANGE SCAN) OF 'I2' 47 STOP 2005 Julian Dyke © juliandyke.com
  • 48. Library Cache 512 x 1 word pointers Library Cache Object Handle 256 x DLL Heap headers ksmgsg_ KGLHD Library struct kgsms Cache KGLHD KGLHD KGLHD 512 x 256 = 131072 buckets Anonymous List KGLHD KGLHD KGLHD KGLHD 48 STOP 2005 Julian Dyke © juliandyke.com
  • 49. Library Cache Object - Parent KGLHD KGLNA Parent SELECT SUM (c2) FROM t1 Name WHERE c3 = 42 AND c4 < 2004 KGLOB Parent Object Heap 0 Parent Handle X$KGLOB Child Handle KGLHD Child 1 16 x 1 word KGLHD pointers Child 2 49 STOP 2005 Julian Dyke © juliandyke.com
  • 50. Library Cache Object - Child Child Statistics Object Subheap KGLHD etc Header KGLOB Heap 0 Child Heap 6 Handle Subquery Header X$KGLOB Subheap Header SELECT Statement 50 STOP 2005 Julian Dyke © juliandyke.com
  • 51. Library Cache - Statement Subquery Header Explain SORT Plan Operation (AGGREGATE) Explain Plan Operation TABLE ACCESS (BY INDEX ROWID) Explain INDEX Plan Operation (RANGE SCAN) 51 STOP 2005 Julian Dyke © juliandyke.com
  • 52. Sort (Aggregate) Output SORT (AGGREGATE) Columns Expression Function Expression Op=SUM Expression Column Expression Variable Column Definition Column Alias Obj =1234 Alias=C2 Col=2 52 STOP 2005 Julian Dyke © juliandyke.com
  • 53. Table Access (By Index Rowid) Output Predicate Columns TABLE ACCESS (BY INDEX ROWID) c4 < 2004 ROWID Variable Expression Expression Condition Column Definition Column Expression Expression Obj =1234 Col=2 Variable Function Expression Op=LT Column Definition Table Alias Expression Expression Obj =1234 Alias=T1 Col=ROWID Column Expression Constant Expression Variable Constant Value=2004 Column Definition Column Alias Obj =1234 Alias=C4 Col=4 53 STOP 2005 Julian Dyke © juliandyke.com
  • 54. Index (Range Scan) Output Predicate Columns INDEX (RANGE SCAN) c3 = 42 Variable Expression Array Column Definition Expression Obj =1234 Col=ROWID Function Expression Op=EQ Expression Expression Column Expression Constant Expression Variable Constant Value=42 Column Definition Column Alias Obj =1234 Alias=C3 Col=3 54 STOP 2005 Julian Dyke © juliandyke.com
  • 55. Shared Pool Reserved Area  Area of memory reserved for large contiguous requests for memory  Reduces fragmentation in shared pool  Only used if no space available in shared pool  Summarised in V$SHARED_POOL_RESERVED  SHARED_POOL_RESERVED_SIZE  specifies size of shared pool in bytes  defaults to 5% of SHARED_POOL_SIZE  _SHARED_POOL_RESERVED_PCT  specifies percentage of shared pool to reserve  defaults to 5%  _SHARED_POOL_RESERVED_MIN_ALLOC  specifies minimum chunk size e.g. 4400 55 © 2005 Julian Dyke juliandyke.com
  • 56. X$KSMSPR  Externalises address, size and class of all chunks in the shared pool Comment ● free memory ADDR RAW(4) ● reserved_stopper INDX NUMBER INST_ID NUMBER Address KSMCHCOM VARCHAR2(16) KSMCHPTR RAW(4) Size in bytes KSMCHSIZ NUMBER KSMCHCLS VARCHAR2(8) Class ●R-free KSMCHTYP NUMBER ●R-freeable KSMCHPAR RAW(4) 56 © 2005 Julian Dyke juliandyke.com
  • 57. Shared Pool Reserved Area 56400000 SELECT ksmchcom,ksmchptr,ksmchsiz,ksmchcls FROM x$ksmspr 56800000 ORDER BY ksmchptr; 56C00000 KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS reserved_stopper 56400024 20 R-freeable 57000000 free memory 56400038 126900 R-free reserved_stopper 5641EFEC 20 R-freeable 57400000 reserved_stopper 56800024 20 R-freeable free memory 56800038 126900 R-free 57800000 reserved_stopper 5681EFEC 20 R-freeable reserved_stopper 56C00024 20 R-freeable 57C00000 free memory 56C00038 126900 R-free 58000000 reserved_stopper 56C1EFEC 20 R-freeable reserved_stopper 57000024 20 R-freeable 57 STOP 2005 Julian Dyke © juliandyke.com
  • 58. Log Buffer 58400000 Guard Page LOG_BUFFER = 524288  2 x 4K guard pages (DEADFACE)  1288 x 512 byte blocks for redo  Each 512 byte includes 16 byte header  Usable redo = 1288 x 496 = 638848 bytes Header - 16 bytes Body - 496 bytes 584A2000 Guard Page 58 STOP 2005 Julian Dyke © juliandyke.com
  • 59. Thank you for your interest For more information and to provide feedback please contact me My e-mail address is: info@juliandyke.com My website address is: www.juliandyke.com 59 © 2005 Julian Dyke juliandyke.com

Hinweis der Redaktion

  1. Sessions are located in the shared pool permanent area. In Oracle 9.2 each session structure occupies 2412 bytes. This includes the structures for session statistics and current waits. It does NOT include the structure for session wait statistics. These are held in another structure, presumably to reduce the number of granules across which the session structure is distributed. By default there are 38 sessions. The pointer array therefore contains 38 x 4-byte pointers. The pointer array can be located from KSUSGA_ (KSUSG) in the fixed SGA.