+ All Categories
Home > Technology > Thanks for the Memory

Thanks for the Memory

Date post: 09-Jun-2015
Category:
Upload: guy-harrison
View: 2,011 times
Download: 3 times
Share this document with a friend
Description:
Presentation on Oracle memory optimization. Presented at Perth AUSOUG 20/20 Conference November 2009.
Popular Tags:
34
© 2009 Quest Software, Inc. ALL RIGHTS RESERVED Thanks for the Memory Guy Harrison Director, Melbourne R&D [email protected] www.guyharrison.net
Transcript
Page 1: Thanks for the Memory

© 2009 Quest Software, Inc. ALL RIGHTS RESERVED

Thanks for the MemoryGuy Harrison

Director, Melbourne R&D

[email protected]

www.guyharrison.net

Page 2: Thanks for the Memory

2

Introductions

Buy Quest Products

Page 3: Thanks for the Memory

3

Human memory is complex • Short Term Sensory Store:

~ 1 second uncompressed raw memory

• Working memory: Limited capacity, requires attention

• Long term memory: physically stored in brain structure; large capacity; indexed strangely

Beyond Bullets Points:

By: Cliff Atkinson

Page 4: Thanks for the Memory

4

Oracle memory is much simpler• Buffer cache memory caches segment data to

avoid read IO.

• PGA is used for program working memory such as

sorting and hashing

• Other areas are less performance critical

Buffer pools

Program Global Area (PGA)Sort area

Hash Area

Data (USER) tablespace

Temporary tablespace

Oracle Session

Page 5: Thanks for the Memory

5

Sort IO can easily dominate datafile IO

1 2 3 4 8 16 32 50 75 100 125 150 175 200 250 3000

10

20

30

40

50

60

70

80

90

100

Table/Index IO CPU Time Temp Segment IO

PGA Memory available (MB)

Tim

e (s

)

Page 6: Thanks for the Memory

6

What consumes PGA memory• Sorts:

– ORDER BY – SORT-MERGE JOIN– UNION, INTERSECT, MINUS– Pre-10GR2 GROUP BY , DISTINCT– Analytic functions: OVER(), LEAD(), LAG(), etc

• Hash Operations:– Hash join– Hash GROUP BY, DISTINCT

• PL/SQL variables– Collections– BULK COLLECT– Parameter passing without NOCOPY

Page 7: Thanks for the Memory

7

PGA Aggregate Target and session memory

0 200 400 600 800 1000 1200 1400 1600 1800 20000

200

400

600

800

1000

1200

Max process PGA Max workarea PGA Total Parallel workarea

PGA_AGGREGATE_TARGET (MB)

Siz

e L

imit

(M

B)

Page 8: Thanks for the Memory

8

Optimal, one-pass, multi-pass

0.499999999999999 4.99999999999999 49.9999999999999 499.9999999999990

10

20

30

40

50

60

70

80

90

100

Sort Memory available (MB)

Tim

e (s

)

Optimal

Single Pass

Mu

lti-pa

ss

Page 9: Thanks for the Memory

9

Sort merge and hash joins

1 10 100 10000

50

100

150

200

250

Hash Join Sort Merge Join

Workarea Memory (MB)

Ela

pse

d T

ime

(s)

Page 10: Thanks for the Memory

10

Estimated SQL memory

Page 11: Thanks for the Memory

11

Actual SQL Memory

Page 12: Thanks for the Memory

12

PGA advice - manual

Page 13: Thanks for the Memory

13

PGA advice - OEM

Page 14: Thanks for the Memory

14

PGA and Sorts – Spotlight on Oracle

Page 15: Thanks for the Memory

15

Opting out of PGA Aggregate Target• Default workarea sizing policies only allow for a session to get

10-20% of the PGA• If a single large sort is in progress, it makes sense to “opt out” of

automatic workarea sizing

Page 16: Thanks for the Memory

16

Shared Memory

Page 17: Thanks for the Memory

17

Modified LRU mechanism

Buffer CakeBuffer Cache

Oracle Session

Page 18: Thanks for the Memory

18

Modified LRU mechanism: Table Scans

Buffer CakeBuffer Cache

Oracle Session

Page 19: Thanks for the Memory

19

Impact of direct path IO

http://guyh.textdriven.com/OPSGSamples/Ch18/temporary_direct.sql

Page 20: Thanks for the Memory

20

The buffer cache “hit rate”

http://guyh.textdriven.com/OPSGSamples/Ch18/hit_rate.sql

Page 21: Thanks for the Memory

21

Multiple buffer pools

KEEP

DEFAULT

0 200 400 600 800 1,000 1,200

325

399

24

637

Other

IO Time

Average query time (ms)

Bu

ffer

Po

ol

Page 22: Thanks for the Memory

22

Buffer Cache advisory: manual

Page 23: Thanks for the Memory

23

Buffer cache advisory: OEM

Page 24: Thanks for the Memory

24

Automatic Shared Memory management (ASMM)

• Default in 10g and recommended (with caveats):– Set Minimum values for key pools (buffer pools, shared pool)– Manually size non-default pools using

V$DB_CACHE_ADVICE– Monitor for memory starvation– Monitor for memory thrashing

• Waits on “SGA: allocation forcing component growth”

Page 25: Thanks for the Memory

25

Memory starvation and thrashing

Page 26: Thanks for the Memory

26

Optimizing overall memory• Optimizing between PGA and SGA are often more significant

than allocating within each area– In 10g optimization is difficult:– Compare PGA and Buffer Cache advisories– Adjust based on IO types (direct read temp vs. physical reads)

• In 11g can use Automatic Memory Management – Risk of thrashing and starvation is greater than with ASMM– Set minimum values for all pools– Manually configure non-default buffer pools

Page 27: Thanks for the Memory

27

Worst case scenario• Trivial memory allocations from PL/SQL programs can steal

vital memory from buffer cache• Situation can become worse if MTS is enabled• Setting minimum values is virtually mandatory

Page 28: Thanks for the Memory

28

Spotlight on Oracle memory management

Page 29: Thanks for the Memory

29

Spotlight on Oracle memory management

Page 30: Thanks for the Memory

30

11g Result Set Cache• Can provide massive improvements for expensive queries on static tables• In memory dynamic materialized view?

Result cache

No Result Cache

0 10,000 20,000 30,000 40,000 50,000 60,000

6,850

59,590

Elapsed time (ms)

Page 31: Thanks for the Memory

31

Result set cache• Caveats:

– Single latch on modifications– Any modification to a dependent table flushes the result sets – Can select statements only at the table level or by inserting a hint

• Bottom line:– Limited effectiveness– Unique candidate SQLs must be low frequency– Tables must be static

Page 32: Thanks for the Memory

32

Things we didn’t talk about

• Shared pool• Redo buffer• Large Pool• Flashback buffer

Page 33: Thanks for the Memory

33

Key take aways

• Don’t emphasize buffer cache tuning at the expense of PGA• Consider opting out of PGA Aggregate Target for large sorts• ASMM and ASM are fine, but set minimums for important

memory pools • Result set cache is promising, but right now is of limited

applicability

Page 34: Thanks for the Memory

© 2009 Quest Software, Inc. ALL RIGHTS RESERVED

End of Presentation

너를 감사하십시요 Thank You Danke Schön

Gracias 有難う御座いました Merci

Grazie Obrigado 谢谢


Recommended