1 Julian Dyke Independent Consultant © 2005 Julian Dyke SGA Internals Web Version juliandyke.com.

Slides:



Advertisements
Similar presentations
The Architecture of Oracle
Advertisements

Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Wait Tree - Locks Waits Disk I/O Library Cache Enqueue Undo TX 6 Row Lock TX 4 ITL Lock HW Lock.
Introduction to Database Systems1 Records and Files Storage Technology: Topic 3.
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA.
File Systems.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Oracle Architecture. Instances and Databases (1/2)
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
15 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Memory.
Oracle Online Features - Golfing Instead of Working on Weekends Oracle World 2003 – Session Sep 2003 Denny Wong Consultant Database Services.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Oracle Architectural Components
Harvard University Oracle Database Administration Session 5 Data Storage.
10 Copyright © 2006, Oracle. All rights reserved. Automatic Shared Memory Management.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
1 Copyright © 2009, Oracle. All rights reserved. Exploring the Oracle Database Architecture.
Oracle Database Administration Database files Logical database structures.
1 © 2006 Julian Dyke Inside RAC Julian Dyke Independent Consultant Web Version juliandyke.com.
Oracle Documentation Oracle DBA Course (9i, 10g, 11g) Lecture 1: Oracle Architectural Components.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Basic Oracle Architecture
CSE 781 – DATABASE MANAGEMENT SYSTEMS Introduction To Oracle 10g Rajika Tandon.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
1 © 2005 Julian Dyke Julian Dyke Independent Consultant juliandyke.com Web Version Native PL/SQL Compilation.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
1 RAC Internals Julian Dyke Independent Consultant Web Version juliandyke.com © 2007 Julian Dyke.
The HDF Group HDF5 Datasets and I/O Dataset storage and its effect on performance May 30-31, 2012HDF5 Workshop at PSI 1.
Oracle9i Performance Tuning Chapter 2 Tuning the Buffer Cache.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Anton TopurovIT-DB 23 April 2013 Introduction to Oracle2.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Outline Introduction to Oracle Memory Structures SGA, PGA, SCA The Specifics of the System Global Area (SGA) Structures Overview of Program Global Areas.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
Harvard University Oracle Database Administration Session 6 Object Storage.
1 Logical I/O Julian Dyke Independent Consultant Web Version juliandyke.com © 2005 Julian Dyke.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown President System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2003.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
1 © 2005 Julian Dyke Reducing Redo Julian Dyke Independent Consultant Web Version juliandyke.com.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
Preface 1Performance Tuning Methodology: A Review Course Structure 1-2 Lesson Objective 1-3 Concepts 1-4 Determining the Worst Bottleneck 1-5 Understanding.
Oracle Architecture - Structure. Oracle Architecture - Structure The Oracle Server architecture 1. Structures are well-defined objects that store the.
IT Database Administration Section 05. Rollback Segments: An Introduction  What are they?  Space within a database used to store “before” images.
8 Copyright © 2006, Oracle. All rights reserved. Tuning the Shared Pool.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
Copyright © 2010 The HDF Group. All Rights Reserved1 Data Storage and I/O in HDF5.
Oracle Database Architectural Components
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
Module 11: File Structure
Initialization Parameters
Database structure and space Management
Oracle Architectural Components
Database Management Systems (CS 564)
Oracle 10g Database Administrator: Implementation and Administration
Lecture 10: Buffer Manager and File Organization
Oracle Memory Internals
Oracle Architectural Components
Presentation transcript:

1 Julian Dyke Independent Consultant © 2005 Julian Dyke SGA Internals Web Version juliandyke.com

© 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

© 2005 Julian Dyke juliandyke.com 3 Introduction  Examples based on  32 bit architecture  Red Hat 2.1 AS  Oracle  Single (non-RAC) instance  Examples affected by  Oracle version  Operating system  Single instance / RAC  Architecture (32/64)  Parameters

© 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

© 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) C AC0 Head Tail 5000F F C AC0 STOP

© 2005 Julian Dyke juliandyke.com 6 Double Linked Lists - Deletion  Double linked lists are more efficient for  insertion  deletion C54 Head Tail 5000F AC0 5000F F C AC0 STOP

© 2005 Julian Dyke juliandyke.com 7 Memory Areas  An Oracle process includes the following memory areas  Executable  PGA/Session Heap  Shared Libraries  SGA  Stack AAA28C A4000 Executable PGA Session Heap Shared Libraries SGA Stack STOP

© 2005 Julian Dyke juliandyke.com 8 Shared Memory  Shared memory can be dumped to trace file using ORADEBUG SETMYPID ORADEBUG IPC $ sqlplus /nolog SQL> CONNECT SYS/ AS SYSDBA Connected SQL> ORADEBUG SETMYPID Statement processed SQL> ORADEBUG IPC Information written to trace file SQL> ORADEBUG TRACEFILE_NAME /var/opt/oracle/admin/LX092001/udump/lx092001_ora_9824.trc

© 2005 Julian Dyke juliandyke.com 9 Area #0 `Fixed Size' containing Subareas 0-0 Total size e5cc Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x x Subarea size Segment size f Area #1 `Variable Size' containing Subareas 1-1 Total size Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x f000 0x f000 Subarea size Segment size Area #2 `Redo Buffers' containing Subareas 2-2 Total size a3000 Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x x Subarea size Segment size a Area #3 `skgm overhead' containing Subareas 3-3 Total size Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x a3000 0x a3000 Subarea size Segment size ORADEBUG IPC - Example Area #0 `Fixed Size' containing Subareas 0-0 Total size e5cc Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x x Subarea size Segment size f Area #1 `Variable Size' containing Subareas 1-1 Total size Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x f000 0x f000 Subarea size Segment size Area #2 `Redo Buffers' containing Subareas 2-2 Total size a3000 Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x x Subarea size Segment size a Area #3 `skgm overhead' containing Subareas 3-3 Total size Minimum Subarea size Area Subarea Shmid Stable Addr Actual Addr x a3000 0x a3000 Subarea size Segment size OS Specific Fixed Area Variable Area Redo Buffers STOP

© 2005 Julian Dyke juliandyke.com 10 V$SGA  Describes sizes of main components in SGA  Used by SHOW SGA command in SQL*Plus NameValue Fixed Size Variable Size Database Buffers Redo Buffers SELECT name, value FROM v$sga;  Based from X$KSMSD  X$KSMSD derived from ksmstv_ (ksmst) in Fixed SGA

© 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 and above  Streams Pool Oracle 10.1 and above  Redo buffers  Buffer Pool includes  Default cache  Keep and Recycle cacheOracle 8.0 and above  2K, 4K, 8K, 16K and 32K cacheOracle and above

© 2005 Julian Dyke juliandyke.com 12 Granules  Introduced in Oracle  SGA divided into granules  In Oracle 9.2 granule size dependent on SGA_MAX_SIZE  4 mb SGA_MAX_SIZE <= 128 mb  16 mbSGA_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

© 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

© 2005 Julian Dyke juliandyke.com 14 Granules SGA_MAX_SIZE = 128M DB_CACHE_SIZE = 48M JAVA_POOL_SIZE = 20M LARGE_POOL_SIZE = 12M SHARED_POOL_SIZE = 20M 128M 4M Note – shared pool size automatically increased from 20M to 32M Buffer Pool 48M Free 16M Fixed SGA 4M Large Pool 12M Shared Pool 32M Java Pool 20M Redo Buffer 4M STOP

© 2005 Julian Dyke juliandyke.com 15 Granule Operations  The following pools can be dynamically resized PoolParameterVersion Shared PoolSHARED_POOL_SIZE9.0.1 and above DefaultDB_CACHE_SIZE9.0.1 and above 2KDB_2K_CACHE_SIZE9.0.1 and above 4KDB_4K_CACHE_SIZE9.0.1 and above 8KDB_8K_CACHE_SIZE9.0.1 and above 16KDB_16K_CACHE_SIZE9.0.1 and above 32KDB_32K_CACHE_SIZE9.0.1 and above KeepDB_KEEP_CACHE_SIZE9.0.1 and above RecycleDB_RECYCLE_CACHE_SIZE9.0.1 and above Large PoolLARGE_POOL_SIZE9.2.0 and above Java PoolJAVA_POOL_SIZE10.1 and above  Streams pool cannot be dynamically resized in Oracle 10.1

© 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

© 2005 Julian Dyke juliandyke.com 17 X$KSMGE  Introduced in Oracle 9.2  Describes individual granules ADDRRAW(4) INDXNUMBER INST_IDNUMBER GRANNUMNUMBER GRANTYPENUMBER GRANSTATEVARCHAR2(16) GRANFLAGSNUMBER LOCALITYNUMBER BASEADDRRAW(4) GRANSIZENUMBER GRANNEXTNUMBER GRANPREVNUMBER INVALID (Free) ALLOCATED Granule Address Granule Size Next granule ID Previous granule ID Granule ID 0Free 2Shared Pool 3Large Pool 4Java Pool 5Buffer Pool

© 2005 Julian Dyke juliandyke.com 18 Granule Dumps  Granules can be dumped using ALTER SESSION SET EVENTS ‘immediate trace name granulelist level ’  where is Heap Level Null Granule255 Home Granule511 Shared Pool767 Large Pool1023 Java Pool1279 Buffer Cache1535

© 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 Fixed SGA Granule Directory Heap Headers 5001D9E8 5001DF STOP

© 2005 Julian Dyke juliandyke.com 20 X$KSMFSV  Externalises name, type, address and size of all variables in fixed SGA ADDRRAW(4) INDXNUMBER INST_IDNUMBER KSMFSNAMVARCHAR2(64) KSMFSTYPVARCHAR2(64) KSMFSADRRAW(4) KSMFSSIZNUMBER Name Type Address Size  SGA can be dumped using ORADEBUG FIXEDSGA

© 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 ’  where is HeapLevel PGA1 SGA2 PGA + SGA3 UGA4 PGA + UGA5 SGA + UGA6 PGA + SGA + UGA7  More detail is included at levels 0x08 0x10 0x18 (OR)

© 2005 Julian Dyke juliandyke.com 22 X$KSMMEM  Externalises contents of all locations in the SGA ADDRRAW(4) INDXNUMBER INST_IDNUMBER KSMMMVALRAW(4) Value Address  Does not work on Windows platforms

© 2005 Julian Dyke juliandyke.com 23 Buffer Cache  Buffer Cache includes 12 x 4M granules  Each granule contains 500 buffers  Buffer Cache contains 6000 buffers C C C DB_CACHE_SIZE = 48M DB_BLOCK_SIZE = 8192 Block Size Buffers Per Granule 4mb16mb STOP

© 2005 Julian Dyke juliandyke.com 24 Buffer Headers  Each buffer has a buffer header  In 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 Granule Buffers STOP

© 2005 Julian Dyke juliandyke.com 25 X$BH  Externalises buffer headers ADDRRAW(4) INDXNUMBER INST_IDNUMBER HLADDRRAW(4) BLSIZNUMBER NXT_HASHRAW(4) PRV_HASHRAW(4) NXT_REPLRAW(4) PRV_REPLRAW(4) TS#NUMBER FILE#NUMBER DBARFILNUMBER DBABLKNUMBER OBJNUMBER BARAW(4) CR_SCN_BASNUMBER Hash List Address Block Size Hash List Replacement List Tablespace# Absolute File Number Relative File Number Block Number Object ID Buffer Address

© 2005 Julian Dyke juliandyke.com 26 Shared Pool C C Shared Pool includes  Permanent Area  Segmented Arrays  Library Cache  Row Cache  Reserved Area Shared Pool occupies  8 x 4M granules = 32M  SHARED_POOL_SIZE = 20M STOP

© 2005 Julian Dyke juliandyke.com 27 V$SGASTAT  Describes sizes of individual components in SGA PoolNameValue fixed sga buffer cache log buffer shared poolenqueues51680 shared poolsessions91656 shared poollibrary cache shared pooldictionary cache shared poolfree memory large poolfree memory java poolfree memory SELECT pool, name, value FROM v$sgastat;

© 2005 Julian Dyke juliandyke.com 28 Permanent Areas SELECT ksmchptr, ksmchsiz FROM x$ksmsp WHERE ksmchcls = 'perm'; AddressSize 5641F F AB6C C1F F C C  Allocated at instance startup  Contain structures such as  processes  sessions  segmented arrays 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

© 2005 Julian Dyke juliandyke.com 30 Sessions X$KSUSE V$SESSION X$KSUSECST V$SESSION_WAIT X$KSUSESTA V$SESSTAT Array of Pointers struct ksusg ksusga_ 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

© 2005 Julian Dyke juliandyke.com 32 Segmented Arrays Call Enqueues Enqueue Resources Segmented Array Header Segmented Array Segmented Array Header Segmented Array STOP

© 2005 Julian Dyke juliandyke.com 33 X$KSMDD  Externalises segmented array headers ADDRRAW(4) INDXNUMBER INST_IDNUMBER NAMEVARCHAR2(30) ELEMENTS_CHUNKNUMBER ITEMS_PTNUMBER INITENTRIESNUMBER NUMENTRIESNUMBER CURENTRIESNUMBER NUMCHUNKSNUMBER ELEMSIZENUMBER FLAGSNUMBER HEAPRAW(4) SECONDARYRAW(4) Name of array Address of parent heap Number of chunks

© 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 Extent 0 Extent 1 Extent 2 Heap Header Free List Chunks STOP

© 2005 Julian Dyke juliandyke.com 35 Chunks  Chunks contain  header  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 Extent Extent Header Chunk Header Chunk Body STOP

© 2005 Julian Dyke juliandyke.com 36 X$KSMSP  Externalises chunks in the shared pool ADDRRAW(4) INDXNUMBER INST_IDNUMBER KSMCHIDXNUMBER KSMCHDURNUMBER KSMCHCOMVARCHAR2(16) KSMCHPTRRAW(4) KSMCHSIZNUMBER KSMCHCLSVARCHAR2(8) KSMCHTYPNUMBER KSMCHPARRAW(4) Description of chunk type Address of chunk Size including header Class ●Perm ●Recreate ●Freeable ●Free ●R-Free ●R-Freeable Address of parent Type (recreate only) ●0x18 - KGL Handle ●0x24 - Fixed Allocation ●0x74 - KQR PO ●0x80 - KQR SO ●0xFFF - Extended header

© 2005 Julian Dyke juliandyke.com 37 Heap Dumps  Heaps can be dumped using ALTER SESSION SET EVENTS ‘immediate trace name heapdump level ’;  where is HeapSummaryDetail PGA11025 SGA22050 UGA44100 CGA – Current Call88200 CGA – User Call LGA – Large Pool

© 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, , 812  increments of 64 bytes - 876, 940, , 4012  then 4108, 8204, 16396, 32780,  Reduces fragmentation

© 2005 Julian Dyke juliandyke.com 39 Free List  Example 16 Heap Header 52 byte chunks 24 byte chunks Buckets 36 byte chunks

© 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 Subheap Header Free List Extent 0Extent 1Extent 2 Chunk

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

© 2005 Julian Dyke juliandyke.com 42 Subheap Dumps  Example - dump the SGA using 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 " ALTER SESSION SET EVENTS ‘immediate trace name heapdump level 2’;  Dump subheap using ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level 1, addr 0x56b95c0c’;

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

© 2005 Julian Dyke juliandyke.com 44 X$KSMHP  Externalises chunks in a subheap ADDRRAW(4) INDXNUMBER INST_IDNUMBER KSMCHDSRAW(4) KSMCHCOMVARCHAR2(16) KSMCHPTRRAW(4) KSMCHSIZNUMBER KSMCHCLSVARCHAR2(8) KSMCHTYPNUMBER KSMCHPARRAW(4) KSMCHOWNRAW(4) Address of parent heap Address of data segment Description of chunk type Address of chunk Size including header Class ●Perm ●Free

© 2005 Julian Dyke juliandyke.com 45 X$KSMHP SQL> SELECT COUNT(*) FROM x$ksmhp; 0 rows SQL> SELECT COUNT(*) FROM x$ksmhp WHERE ksmchds = HEXTORAW ('5755E798'); COUNT(*) SQL> SELECT kglobhd6 FROM x$kglob WHERE kglnaobj = 'SELECT SUM(c1) FROM t1' AND kglhdadr != kglhdpar; KGLOBHD E798 SQL> SELECT COUNT(*) FROM x$ksmhp; COUNT(*) 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

© 2005 Julian Dyke juliandyke.com 47 Library Cache  For example SELECT SUM(c2) FROM t1 WHERE c3 = 42 AND c4 < 2004; 0SELECT STATEMENT 10SORT (AGGREGATE) 21TABLE ACCESS (BY INDEX ROWID) OF 'T1' 32INDEX (RANGE SCAN) OF 'I2' CREATE TABLE t1 ( c1 NUMBER, c2 NUMBER, c3 NUMBER, c4 NUMBER ); CREATE INDEX i1 ON t1 (c1); CREATE INDEX i2 ON t1 (c3); STOP

© 2005 Julian Dyke juliandyke.com 48 Library Cache struct kgsms ksmgsg_ Heap Library Cache KGLHD Anonymous List KGLHD 512 x 1 word pointers 256 x DLL headers Library Cache Object Handle 512 x 256 = buckets STOP

© 2005 Julian Dyke juliandyke.com 49 Library Cache Object - Parent 16 x 1 word pointers KGLHD Parent Object KGLNA SELECT SUM (c2) FROM t1 WHERE c3 = 42 AND c4 < 2004 Parent Name Child Handle KGLHD Child 1 Child 2 Heap 0 KGLOB X$KGLOB Parent Handle KGLHD STOP

© 2005 Julian Dyke juliandyke.com 50 Library Cache Object - Child KGLHD Child Handle Child Object SELECT Statement Heap 6 KGLOB Subheap Header Heap 0 Subquery Header Statistics etc X$KGLOB STOP

© 2005 Julian Dyke juliandyke.com 51 Library Cache - Statement Subquery Header Operation Explain Plan SORT (AGGREGATE) Explain Plan Operation TABLE ACCESS (BY INDEX ROWID) Operation INDEX (RANGE SCAN) STOP

© 2005 Julian Dyke juliandyke.com 52 Sort (Aggregate) SORT (AGGREGATE) Output Columns Column Definition Obj =1234 Col=2 Column Alias Alias=C2 Expression Function Expression Op=SUM Column Expression Expression Variable STOP

© 2005 Julian Dyke juliandyke.com 53 Table Access (By Index Rowid) Column Definition Obj =1234 Col=2 Column Definition Obj =1234 Col=4 Column Alias Alias=C4 Expression Function Expression Op=LT Column Expression Constant Expression Constant Value=2004 Expression Variable TABLE ACCESS (BY INDEX ROWID) Output Columns Predicate c4 < 2004 Condition Column Definition Obj =1234 Col=ROWID Table Alias Alias=T1 Column Expression Expression Variable ROWID Expression STOP

© 2005 Julian Dyke juliandyke.com 54 Index (Range Scan) Column Definition Obj =1234 Col=ROWID Column Definition Obj =1234 Col=3 Column Alias Alias=C3 Expression Array Expression Function Expression Op=EQ Column Expression Constant Expression Constant Value=42 Expression Variable INDEX (RANGE SCAN) Output Columns Predicate c3 = 42 Variable 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

© 2005 Julian Dyke juliandyke.com 56 X$KSMSPR  Externalises address, size and class of all chunks in the shared pool ADDRRAW(4) INDXNUMBER INST_IDNUMBER KSMCHCOMVARCHAR2(16) KSMCHPTRRAW(4) KSMCHSIZNUMBER KSMCHCLSVARCHAR2(8) KSMCHTYPNUMBER KSMCHPARRAW(4) Comment ● free memory ● reserved_stopper Address Size in bytes Class ●R-free ●R-freeable

© 2005 Julian Dyke juliandyke.com 57 Shared Pool Reserved Area SELECT ksmchcom,ksmchptr,ksmchsiz,ksmchcls FROM x$ksmspr ORDER BY ksmchptr; KSMCHCOMKSMCHPTRKSMCHSIZKSMCHCLS reserved_stopper R-freeable free memory R-free reserved_stopper5641EFEC20R-freeable reserved_stopper R-freeable free memory R-free reserved_stopper5681EFEC20R-freeable reserved_stopper56C R-freeable free memory56C R-free reserved_stopper56C1EFEC20R-freeable reserved_stopper R-freeable KSMCHCOMKSMCHPTRKSMCHSIZKSMCHCLS reserved_stopper R-freeable free memory R-free reserved_stopper5641EFEC20R-freeable reserved_stopper R-freeable free memory R-free reserved_stopper5681EFEC20R-freeable reserved_stopper56C R-freeable free memory56C R-free reserved_stopper56C1EFEC20R-freeable reserved_stopper R-freeable C C STOP

© 2005 Julian Dyke juliandyke.com 58 Log Buffer  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 = bytes LOG_BUFFER = Guard Page Header - 16 bytes Body bytes A2000 STOP

© 2005 Julian Dyke juliandyke.com 59 Thank you for your interest For more information and to provide feedback please contact me My address is: My website address is: