Você está na página 1de 38

Monitoring and Managing Memory

Copyright 2008, Oracle. All rights reserved.

Objectives
After completing this lesson, you should be able to: Describe the memory components in the SGA Implement Automatic Shared Memory Management Manually configure SGA parameters onfigure automatic !GA memory management

8-2

Copyright 2008, Oracle. All rights reserved.

Memory Management: Overvie"


D#As must consider memory management to be a crucial part of their job because: $here is a finite amount of memory available Allocating more memory to serve certain types of functions can improve overall performance Automatically tuned memory allocation is often the appropriate configuration, but specific environments or even short%term conditions may re&uire further attention

8-3

Copyright 2008, Oracle. All rights reserved.

Oracle Memory Structures

Server process *

!GA

Server process +

!GA

#ac,% ground process

!GA

SGA Shared pool Streams pool )arge pool -eep buffer cache (ecycle buffer cache 'ava pool Database buffer cache (edo log buffer n- bloc, si.e buffer caches

8-4

Copyright 2008, Oracle. All rights reserved.

Oracle Me ory !tr"ct"res #"ll $otes %age

8-5

Copyright 2008, Oracle. All rights reserved.

#uffer ache
SGA
Server )(1 lists hec,point &ueue D# buffer cache

/ / / /

/ / / / D#0n DB_BLOCK_SIZE DB_CACHE_SIZE DB_RECYCLE_CACHE_SIZE DB_KEEP_CACHE_SIZE

Data files
8-& Copyright 2008, Oracle. All rights reserved.

$otes O(ly !lide

8-'

Copyright 2008, Oracle. All rights reserved.

1sing Multiple #uffer !ools

SGA
D# buffer caches

(ecycle pool

-eep pool

Default pool

8-8

Copyright 2008, Oracle. All rights reserved.

1sing Multiple #uffer !ools

CREATE INDEX cust_idx STORAGE (BU ER_POOL KEEP !" ALTER TABLE #$%cust#&$'s STORAGE (BU ER_POOL RECYCLE!" ALTER INDEX #$%cust_()*&$_ix STORAGE (BU ER_POOL KEEP!"

8-)

Copyright 2008, Oracle. All rights reserved.

Shared !ool
Si.e is specified by using SHARED_POOL_SIZE/ )ibrary cache contains statement te2t, parsed code, and e2ecution plan/ Data dictionary cache contains definitions for tables, columns, and privileges from the data dictionary tables/ $he 1ser Global Area 31GA4 contains session information if using Oracle shared server/
Shared pool
Shared pool

)ibrary cache Shared pool Data dictionary cache 1GA

8 - *0

Copyright 2008, Oracle. All rights reserved.

)arge !ool
an be configured as a separate memory area in the SGA Is si.ed by the LARGE_POOL_SIZE parameter Is used to store data in memory for:
+ 1GA + #ac,up and restore operations + !arallel &uery messaging
Redo logDatabase buffer buffer cache Shared pool )ibrary cache Dictionary cache Session !arallel
8 - ** Copyright 2008, Oracle. All rights reserved.

Large pool 1GA #ac,up

'ava !ool

an be configured as a separate memory area in the SGA Is si.ed by the +A,A_POOL_SIZE parameter Is used to store data in memory for all session% specific 'ava code and data "ithin the '5M
Redo logDatabase buffer buffer cache Shared pool )ibrary cache Large pool

Dictionary cache

Java pool

8 - *2

Copyright 2008, Oracle. All rights reserved.

(edo )og #uffer


Redo log Database buffer buffer cache Shared pool )ibrary cache

Dictionary cache

Server process
ontrol files

)G0(

A( n

S-L. UPDATE $&/(#0$$s 1 SET s*(*'02s*(*'034%4 5 6HERE $&/(#0$$_id2758"

Data files (edo log files

Archived log files

8 - *3

Copyright 2008, Oracle. All rights reserved.

Automatic Shared Memory Management: Overvie"


Automatically adapts to "or,load changes Ma2imi.es memory utili.ation 6elps eliminate out%of%memory errors
#uffer cache 72ample: )arge pool Shared pool 'ava pool Streams pool Online users
8 - *4

#uffer cache )arge pool Shared pool 'ava pool Streams pool #atch jobs

Copyright 2008, Oracle. All rights reserved.

#enefits of Automatic Shared Memory Management


DB_CACHE_SIZE SHARED_POOL_SIZE LARGE_POOL_SIZE +A,A_POOL_SIZE STREA9S_POOL_SIZE

$otal SGA si.e

SGA_TARGET

8 - *5

Copyright 2008, Oracle. All rights reserved.

6o" ASMM 0or,s


ASMM is based on "or,load information that 99AN captures in the bac,ground/ 99AN uses memory advisors/ Memory is moved to "here it is needed the most/ If an S!8I)7 is used 3"hich is recommended4:
+ omponent si.es are saved across shutdo"ns/ + Saved values are used to bootstrap component si.es/ + $here is no need to relearn optimal values/

8 - *&

Copyright 2008, Oracle. All rights reserved.

onfiguring ASMM by 1sing Database ontrol

8 - *'

Copyright 2008, Oracle. All rights reserved.

Manually onfiguring ASMM


$o have minimum si.es for some of the memory components, you should manually configure those component si.es: If the automatically computed si.es do not serve your purpose for some reason If there are short pea,s or valleys in re&uired memory that are not detected by ASMM If you simply "ant a guaranteed minimum amount of memory for a specific component

8 - *8

Copyright 2008, Oracle. All rights reserved.

Manually onfiguring ASMM

Autotuned Shared pool

Autotuned Database buffer cache (edo log buffer )arge pool Autotuned $otal SGA si.e 9 : G#

Autotuned Streams pool -eep buffer pool

'ava pool Autotuned

8i2ed SGA

SGA_TARGET 2 :G STATISTICS_LE,EL 2 TYPICAL


8 - *) Copyright 2008, Oracle. All rights reserved.

Co(,ig"ratio( -(otes o(ly slide.

8 - 20

Copyright 2008, Oracle. All rights reserved.

#ehavior of Autotuned SGA !arameters


0hen SGA_TARGET is not set or is set to .ero:
+ Autotuned parameters behave as normal + SHARED_POOL_SIZE may need to be increased from settings used in earlier database versions SELECT SU9(;0t$s!<4=1><4=1> si?$_&; RO9 @AsB*st*t 6HERE /##( 2 CsD*'$d /##(C"

0hen SGA_TARGET is set to a non.ero value:


+ Default value of autotuned parameters is .ero + $he specified value is used as a minimum si.e

SELECT c#&/#)$)tE cu''$)t_si?$<4=1><4=1> si?$_&; RO9 @AsB*_d0)*&ic_c#&/#)$)ts"

8 - 2*

Copyright 2008, Oracle. All rights reserved.

#ehavior of Manually $uned SGA !arameters


Some components are not autotuned/
+ KEEP and RECYCLE buffer caches + Multiple bloc, si.e caches

$hese components must be manually configured using database parameters/ $he memory used by these components reduces the amount of memory available for autotuning the SGA/

8 - 22

Copyright 2008, Oracle. All rights reserved.

1sing the ,APARA9ETER 5ie"

SGA_TARGET 2 :G DB_CACHE_SIZE 2 = +A,A_POOL_SIZE 2 = LARGE_POOL_SIZE 2 = SHARED_POOL_SIZE 2 = STREA9S_POOL_SIZE 2 = SELECT )*&$E @*(u$E isd$F*u(t RO9 @A/*'*&$t$' 6HERE )*&$ LIKE CGsi?$C"

8 - 23

Copyright 2008, Oracle. All rights reserved.

Modifying the SGA_TARGET !arameter


$he SGA_TARGET initiali.ation parameter:
+ Is dynamic + an be increased up to SGA_9AX_SIZE + an be reduced until all components reach their minimum si.e

A change in the value of SGA_TARGET affects only automatically si.ed components/

8 - 24

Copyright 2008, Oracle. All rights reserved.

Disabling ASMM
Setting SGA_TARGET to .ero disables autotuning/ Autotuned parameters are set to their current si.es/ $he SGA si.e as a "hole is unaffected/
SGA si.e 9 : G# SGA si.e 9 : G# !arameters: sB*_t*'B$t 2 = d;_c*cD$_si?$ 2 HG sD*'$d_/##(_si?$ 2 1G (*'B$_/##(_si?$ 2 H419 I*@*_/##(_si?$ 2 1H89 st'$*&s_/##(_si?$ 2 1H89

!arameters: sB*_t*'B$t 2 :G sD*'$d_/##(_si?$ 2 4G Original values

8 - 25

Copyright 2008, Oracle. All rights reserved.

Manually (esi.ing Dynamic SGA !arameters


8or autotuned parameters, manual resi.ing:
+ (esults in immediate component resi.e if the ne" value is greater than the current si.e + hanges the minimum si.e if the ne" value is smaller than the current si.e

(esi.ing manually tuned parameters affects only the tunable portion of the SGA/

8 - 2&

Copyright 2008, Oracle. All rights reserved.

!rogram Global Area 3!GA4


!GA
Server process !GA

!rivate ursor Session S;) and S;) memory areas area

0or, area

Dedicated connections

Shared server

!GA

Shared server connections

Shared pool or large pool

!GA

8 - 2'

Copyright 2008, Oracle. All rights reserved.

$otes O(ly !lide

8 - 28

Copyright 2008, Oracle. All rights reserved.

Automatic !GA Memory Management


Dynamically adjusts the amount of !GA memory dedicated to "or, areas, on the basis of the PGA_AGGREGATE_TARGET parameter 6elps ma2imi.e the performance of all the memory% intensive S;) operations Is enabled by default

8 - 2)

Copyright 2008, Oracle. All rights reserved.

!GA Management (esources


Statistics to manage the PGA_AGGREGATE_TARGET initiali.ation parameter, such as PGA c*cD$ Dit /$'c$)t*B$ 5ie"s for monitoring the !GA "or, area include:
+ + + + + @AsJ(_K#'L*'$*_Dist#B'*& @A/B*st*t @AsJ(_K#'L*'$*_*cti@$ @AsJ(_K#'L*'$* @At$&/s$B_us*B$

5ie"s to assist in si.ing the !GA "or, area are:


+ @A/B*_t*'B$t_*d@ic$ + @A/B*_t*'B$t_*d@ic$_Dist#B'*&

8 - 30

Copyright 2008, Oracle. All rights reserved.

1sing the Memory Advisor to Si.e the SGA

8 - 3*

Copyright 2008, Oracle. All rights reserved.

1sing the Memory Advisor to Si.e the !GA

8 - 32

Copyright 2008, Oracle. All rights reserved.

7fficient Memory 1sage: Guidelines


$ry to fit the SGA into physical memory/ $une for a high buffer cache hit ratio, "ith the follo"ing caveats:
+ 7ven valid and necessary full table scans lo"er it/ + It is possible that unnecessary repeated reads of the same bloc,s are artificially raising it/

1se the Memory Advisor/

8 - 33

Copyright 2008, Oracle. All rights reserved.

/,,icie(t Me ory 0sage1 2"ideli(es -(otes o(ly slide.

8 - 34

Copyright 2008, Oracle. All rights reserved.

Memory $uning Guidelines for the )ibrary ache


7stablish formatting conventions for developers so that S;) statements match in the cache/ 1se bind variables/ 7liminate unnecessary duplicate S;)/ onsider using CURSOR_SHARING/ 1se !)<S;) "hen possible/ ache se&uence numbers/ !in objects in the library cache/

8 - 35

Copyright 2008, Oracle. All rights reserved.

Me ory 3"(i(g 2"ideli(es ,or the 4i5rary Cache -(otes o(ly slide.

8 - 3&

Copyright 2008, Oracle. All rights reserved.

Summary
In this lesson, you should have learned ho" to: Describe the memory components in the SGA Implement Automatic Shared Memory Management Manually configure SGA parameters 1se automatic !GA memory management

8 - 3'

Copyright 2008, Oracle. All rights reserved.

!ractice Overvie": 1sing ASMM to orrect a Memory Allocation !roblem


$his practice covers the follo"ing topics: Diagnosing a memory allocation problem 7nabling Automatic Shared Memory Management

8 - 38

Copyright 2008, Oracle. All rights reserved.

Você também pode gostar