Professional Documents
Culture Documents
Internals
Julian Dyke
Independent Consultant
Web Version
1
Agenda
Introduction
SGA
Granules
Fixed SGA
Buffer Cache
Shared Pool
Permanent Areas
Heaps
Subheaps
Library Cache
Reserved Area
Log Buffer
Conclusion
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
Word Length
Also affects
size of some integer variables e.g. int
word alignment
Head
Tail
5000F430
5000F430
5000F430
STOP
55443080
55845C54
52175AC0
Head
Tail
5000F430
55443080
52175AC0
STOP
55443080
55845C54
5000F430
55845C54
52175AC0
55443080
52175AC0
5000F430
55845C54
Memory Areas
Executable
PGA/Session Heap
Shared Libraries
SGA
Stack
08048000
Executable
0AAA28C0
PGA
Session Heap
40000000
50000000
Shared
Libraries
SGA
584A4000
Stack
STOP
Shared Memory
001638400x000000500000000x00000050000000
FixedSubareasizeSegmentsize
Area
000000000006f0000000000008800000
Area#1`VariableSize'containingSubareas11
Totalsize0000000008000000MinimumSubareasize00400000
AreaSubareaShmidStableAddrActualAddr
111638400x0000005006f0000x0000005006f000
Variable
Area
SubareasizeSegmentsize
00000000083910000000000008800000
Area#2`RedoBuffers'containingSubareas22
Totalsize00000000000a3000MinimumSubareasize00000000
AreaSubareaShmidStableAddrActualAddr
221638400x000000584000000x00000058400000
SubareasizeSegmentsize
Redo Buffers
00000000000a30000000000008800000
Area#3`skgmoverhead'containingSubareas33
Totalsize0000000000001000MinimumSubareasize00000000
AreaSubareaShmidStableAddrActualAddr
331638400x000000584a30000x000000584a3000
OS Specific
SubareasizeSegmentsize
00000000000010000000000008800000
STOP
V$SGA
452044
Variable Size
83886080
Database Buffers
50331648
Redo Buffers
Value
667648
Contains
Fixed SGA
Buffer Pool
Shared Pool
Large Pool
Java Pool
Streams Pool
Redo buffers
Buffer Pool includes
Default cache
Keep and Recycle cache
2K, 4K, 8K, 16K and 32K cache
Granules
Granules
Granules
SGA_MAX_SIZE = 128M
DB_CACHE_SIZE = 48M
JAVA_POOL_SIZE = 20M
LARGE_POOL_SIZE = 12M
SHARED_POOL_SIZE = 20M
4M
Fixed SGA 4M
Free 16M
Buffer Pool 48M
128M
STOP
Redo Buffer 4M
4M
Granule Operations
Parameter
Version
Shared Pool
SHARED_POOL_SIZE
Default
DB_CACHE_SIZE
2K
DB_2K_CACHE_SIZE
4K
DB_4K_CACHE_SIZE
8K
DB_8K_CACHE_SIZE
16K
DB_16K_CACHE_SIZE
32K
DB_32K_CACHE_SIZE
Keep
DB_KEEP_CACHE_SIZE
Recycle
DB_RECYCLE_CACHE_SIZE
Large Pool
LARGE_POOL_SIZE
Java Pool
JAVA_POOL_SIZE
Granule Views
X$KSMGE
Introduced
in Oracle 9.2
Describes individual granules
ADDR
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
GRANNUM
NUMBER
GRANTYPE
NUMBER
GRANSTATE
VARCHAR2(16)
GRANFLAGS
NUMBER
LOCALITY
NUMBER
BASEADDR
RAW(4)
GRANSIZE
NUMBER
GRANNEXT
NUMBER
GRANPREV
NUMBER
Granule ID
0
2
3
4
5
Free
Shared Pool
Large Pool
Java Pool
Buffer Pool
INVALID (Free)
ALLOCATED
Granule Address
Granule Size
Next granule ID
Previous granule ID
Granule Dumps
where <level> is
Heap
Level
Null Granule
255
Home Granule
511
Shared Pool
767
Large Pool
1023
Java Pool
1279
Buffer Cache
1535
Fixed SGA
Fixed SGA
5001D9E8
Granule Directory
5001DF50
Heap Headers
STOP
X$KSMFSV
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMFSNAM
VARCHAR2(64)
KSMFSTYP
VARCHAR2(64)
KSMFSADR
RAW(4)
KSMFSSIZ
NUMBER
Name
Type
Address
Size
where <level> is
Heap
Level
PGA
SGA
PGA + SGA
UGA
PGA + UGA
SGA + UGA
X$KSMMEM
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMMMVAL
RAW(4)
Address
Value
Buffer Cache
51400000
DB_CACHE_SIZE = 48M
DB_BLOCK_SIZE = 8192
51800000
51C00000
52000000
52400000
52800000
52C00000
Block
Size
53000000
4mb
53400000
53800000
53C00000
54000000
STOP
Buffers Per
Granule
16mb
2048
1875
7503
4096
979
3916
8192
500
2002
16384
253
1012
32768
127
509
Buffer Headers
Buffer
Headers
Buffers
Granule
STOP
X$BH
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
Block Size
HLADDR
RAW(4)
BLSIZ
NUMBER
NXT_HASH
RAW(4)
PRV_HASH
RAW(4)
NXT_REPL
RAW(4)
PRV_REPL
RAW(4)
TS#
NUMBER
FILE#
NUMBER
DBARFIL
NUMBER
Block Number
DBABLK
NUMBER
OBJ
NUMBER
Object ID
BA
RAW(4)
Buffer Address
CR_SCN_BAS
NUMBER
Hash List
Replacement List
Tablespace#
Absolute File Number
Shared Pool
56400000
Permanent Area
Segmented Arrays
56C00000
Library Cache
57000000
Row Cache
Reserved Area
56800000
57400000
57800000
57C00000
58000000
STOP
8 x 4M granules = 32M
SHARED_POOL_SIZE = 20M
V$SGASTAT
Name
fixed sga
buffer cache
Value
452044
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
Permanent Areas
3967868
5681F000
2718736
56C00000
57000000
57400000
57800000
57C00000
905116
56C1F00
4063188
5701F000
4067328
STOP
56800000
Size
5641F000
56AB6C10
56400000
58000000
Sessions
Sessions
ksusga_
struct ksusg
Array of
Pointers
STOP
X$KSUSE
V$SESSION
X$KSUSESTA
V$SESSTAT
X$KSUSECST
V$SESSION_WAIT
Segmented Arrays
Segmented Arrays
Segmented
Arrays
Call
Segmented
Array
Segmented
Array
Segmented
Header
Array
Segmented
Array
Header
STOP
Enqueues
Enqueue
Resources
X$KSMDD
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
NAME
VARCHAR2(30)
ELEMENTS_CHUNK
NUMBER
ITEMS_PT
NUMBER
INITENTRIES
NUMBER
NUMENTRIES
NUMBER
CURENTRIES
NUMBER
NUMCHUNKS
NUMBER
ELEMSIZE
NUMBER
FLAGS
NUMBER
HEAP
RAW(4)
SECONDARY
RAW(4)
Name of array
Number of
chunks
Address of parent
heap
Heaps
Extent 0
Extent 1
Extent 2
Header
Free List
STOP
Chunks
Chunks
Chunks contain
header
body
Chunks can be
permanent
recreatable
freeable
free
STOP
Extent
Extent
Header
Chunk
Header
Chunk
Body
X$KSMSP
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMCHIDX
NUMBER
KSMCHDUR
NUMBER
KSMCHCOM
VARCHAR2(16)
KSMCHPTR
RAW(4)
KSMCHSIZ
NUMBER
KSMCHCLS
VARCHAR2(8)
KSMCHTYP
NUMBER
KSMCHPAR
RAW(4)
Heap Dumps
where <level> is
Heap
Summary
Detail
PGA
1025
SGA
2050
UGA
4100
8200
16
16400
32
32800
Free List
Reduces fragmentation
Free List
Example
Heap Header
Buckets
16
20
24
28
32
36
40
44
48
52
56
60
64
24 byte chunks
36 byte chunks
52 byte chunks
Subheaps
Free
List
Extent 0
Extent 1
Chunk
Extent 2
Subheap Dumps
Subheap Dumps
Chunk56b94dc8sz=304recreate"KGLhandles"latch=0x56efd918
Chunk56b94ef8sz=560freeable"librarycache"ds=0x56b95c0c
Chunk56b95128sz=540recreate"KQRPO"latch=(nil)
Chunk56b95344sz=540recreate"KQRPO"latch=0x56d719f4
Chunk56b95560sz=1116freeable"KGLSheap"ds=0x56b96d1c
Chunk56b959bcsz=20free""
Chunk56b959d0sz=560recreate"librarycache"latch=(nil)
ds56b95c0csz=1120ct=2
56b94ef8sz=560
Chunk56b95c00sz=96freeable"librarycache"
Subheap Dumps
Extent 0
Extent 1
Extent 2
Free List
free
free
"
"
"
"
alo=260
"
"
alo=512
"
"
alo=172
"
"
"
"
"perm
"perm
"perm
"
"
"
first):
perm
perm
perm
alo=260
alo=512
alo=172
X$KSMHP
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMCHDS
RAW(4)
KSMCHCOM
VARCHAR2(16)
KSMCHPTR
RAW(4)
KSMCHSIZ
NUMBER
KSMCHCLS
VARCHAR2(8)
KSMCHTYP
NUMBER
KSMCHPAR
RAW(4)
KSMCHOWN
RAW(4)
X$KSMHP
SQL> SELECT COUNT(*) FROM x$ksmhp;
COUNT(*)
-------SQL> SELECT
COUNT(*) FROM
0
x$ksmhp;
SQL>
SELECT kglobhd6 FROM x$kglob
0 rows
WHERE kglnaobj = 'SELECT SUM(c1) FROM t1'
AND kglhdadr != kglhdpar;
KGLOBHD6
-------5755E798
SQL> SELECT COUNT(*) FROM x$ksmhp
WHERE ksmchds = HEXTORAW ('5755E798');
COUNT(*)
-------1
STOP
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
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
1
2
3
0
1
2
SELECT STATEMENT
SORT (AGGREGATE)
TABLE ACCESS (BY INDEX ROWID) OF 'T1'
INDEX (RANGE SCAN) OF 'I2'
STOP
Library Cache
512 x 1 word
pointers
Library Cache
Object Handle
256 x DLL
headers
Heap
ksmgsg_
struct kgsms
KGLHD
Library
Cache
KGLHD
KGLHD
KGLHD
512 x 256 =
131072 buckets
Anonymous
List
STOP
KGLHD
KGLHD
KGLHD
KGLHD
KGLHD
Parent
Object
Heap 0
X$KGLOB
Child 1
16 x 1 word
pointers
STOP
Parent
Name
Child 2
Child
Handle
KGLHD
KGLHD
Child
Object
Subheap
Header
Statistics
etc
KGLOB
Heap 0
Heap 6
Child
Handle
Subquery
Header
X$KGLOB
STOP
Subheap
Header
SELECT
Statement
Explain
Plan
Operation
SORT
(AGGREGATE)
Explain
Plan
Operation
Explain
Plan
Operation
INDEX
(RANGE SCAN)
STOP
Sort (Aggregate)
Output
Columns
SORT (AGGREGATE)
Expression
Function Expression
Op=SUM
Expression
Column Expression
Variable
Column Definition
Obj =1234
Col=2
STOP
Column Alias
Alias=C2
Column Definition
Obj =1234
Col=2
Column Expression
Condition
Expression
Variable
Column Definition
Obj =1234
Col=ROWID
Predicate
c4 < 2004
Function Expression
Op=LT
Table Alias
Alias=T1
Expression
Column Expression
Expression
Constant Expression
Variable
Column Definition
Obj =1234
Col=4
STOP
Constant
Value=2004
Column Alias
Alias=C4
Predicate
c3 = 42
Expression Array
Column Definition
Obj =1234
Col=ROWID
Expression
Function Expression
Op=EQ
Expression
Column Expression
Expression
Constant Expression
Variable
Column Definition
Obj =1234
Col=3
STOP
Constant
Value=42
Column Alias
Alias=C3
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
X$KSMSPR
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMCHCOM
VARCHAR2(16)
KSMCHPTR
RAW(4)
KSMCHSIZ
NUMBER
KSMCHCLS
VARCHAR2(8)
KSMCHTYP
NUMBER
KSMCHPAR
RAW(4)
free memory
reserved_stopper
Address
Size in bytes
Class
R-free
R-freeable
56800000
KSMCHCOM
KSMCHPTR
reserved_stopper
56400024
free memory
56400038
reserved_stopper
5641EFEC
20 R-freeable
reserved_stopper
56800024
20 R-freeable
free memory
56800038
reserved_stopper
5681EFEC
20 R-freeable
reserved_stopper
56C00024
20 R-freeable
free memory
56C00038
reserved_stopper
56C1EFEC
20 R-freeable
reserved_stopper
57000024
20 R-freeable
STOP
56400000
KSMCHSIZ KSMCHCLS
20 R-freeable
56C00000
57000000
126900 R-free
126900 R-free
126900 R-free
57400000
57800000
57C00000
58000000
Log Buffer
Guard Page
58400000
LOG_BUFFER = 524288
584A2000
Guard Page
STOP