Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Thanks for the Memory


Published on

Presentation on Oracle memory optimization. Presented at Perth AUSOUG 20/20 Conference November 2009.

Published in: Technology, Business
  • Be the first to comment

Thanks for the Memory

  1. 1. Thanks for the Memory<br />Guy Harrison<br />Director, Melbourne R&D <br /><br /><br />
  2. 2. Introductions<br />Buy Quest Products <br />
  3. 3. Human memory is complex <br />Short Term Sensory Store: ~ 1 second uncompressed raw memory<br />Working memory: Limited capacity, requires attention <br />Long term memory: physically stored in brain structure; large capacity; indexed strangely<br />Beyond Bullets Points:<br />By: Cliff Atkinson<br />
  4. 4. Oracle memory is much simpler<br /><ul><li>Buffer cache memory caches segment data to avoid read IO.
  5. 5. PGA is used for program working memory such as sorting and hashing
  6. 6. Other areas are less performance critical</li></li></ul><li>Sort IO can easily dominate datafile IO<br />
  7. 7. What consumes PGA memory<br />Sorts:<br />ORDER BY <br />SORT-MERGE JOIN<br />UNION, INTERSECT, MINUS<br />Pre-10GR2 GROUP BY , DISTINCT<br />Analytic functions: OVER(), LEAD(), LAG(), etc<br />Hash Operations:<br />Hash join<br />Hash GROUP BY, DISTINCT<br />PL/SQL variables<br />Collections<br />BULK COLLECT<br />Parameter passing without NOCOPY<br />
  8. 8. PGA Aggregate Target and session memory<br />
  9. 9. Optimal, one-pass, multi-pass<br />Multi-pass<br />Single Pass<br />Optimal<br />
  10. 10. Sort merge and hash joins <br />
  11. 11. Estimated SQL memory<br />
  12. 12. Actual SQL Memory<br />
  13. 13. PGA advice - manual<br />
  14. 14. PGA advice - OEM<br />
  15. 15. PGA and Sorts – Spotlight on Oracle <br />
  16. 16. Opting out of PGA Aggregate Target<br />Default workarea sizing policies only allow for a session to get 10-20% of the PGA<br />If a single large sort is in progress, it makes sense to “opt out” of automatic workarea sizing<br />
  17. 17. Shared Memory<br />
  18. 18. Modified LRU mechanism <br />Oracle Session<br />Buffer Cake<br />Buffer Cache<br />
  19. 19. Modified LRU mechanism: Table Scans <br />Oracle Session<br />Buffer Cake<br />Buffer Cache<br />
  20. 20. Impact of direct path IO<br /><br />
  21. 21. The buffer cache “hit rate” <br /><br />
  22. 22. Multiple buffer pools <br />
  23. 23. Buffer Cache advisory: manual<br />
  24. 24. Buffer cache advisory: OEM<br />
  25. 25. Automatic Shared Memory management (ASMM) <br />Default in 10g and recommended (with caveats):<br />Set Minimum values for key pools (buffer pools, shared pool)<br />Manually size non-default pools using V$DB_CACHE_ADVICE<br />Monitor for memory starvation<br />Monitor for memory thrashing <br />Waits on “SGA: allocation forcing component growth”<br />
  26. 26. Memory starvation and thrashing<br />
  27. 27. Optimizing overall memory<br />Optimizing between PGA and SGA are often more significant than allocating within each area<br />In 10g optimization is difficult:<br />Compare PGA and Buffer Cache advisories<br />Adjust based on IO types (direct read temp vs. physical reads)<br />In 11g can use Automatic Memory Management <br />Risk of thrashing and starvation is greater than with ASMM<br />Set minimum values for all pools<br />Manually configure non-default buffer pools <br />
  28. 28. Worst case scenario<br />Trivial memory allocations from PL/SQL programs can steal vital memory from buffer cache<br />Situation can become worse if MTS is enabled<br />Setting minimum values is virtually mandatory<br />
  29. 29. Spotlight on Oracle memory management<br />
  30. 30. Spotlight on Oracle memory management<br />
  31. 31. 11g Result Set Cache<br />Can provide massive improvements for expensive queries on static tables<br />In memory dynamic materialized view? <br />
  32. 32. Result set cache<br />Caveats:<br />Single latch on modifications<br />Any modification to a dependent table flushes the result sets <br />Can select statements only at the table level or by inserting a hint<br />Bottom line:<br />Limited effectiveness<br />Unique candidate SQLs must be low frequency<br />Tables must be static<br />
  33. 33. Things we didn’t talk about <br />Shared pool<br />Redo buffer<br />Large Pool<br />Flashback buffer<br />
  34. 34. Key take aways<br />Don’t emphasize buffer cache tuning at the expense of PGA<br />Consider opting out of PGA Aggregate Target for large sorts<br />ASMM and ASM are fine, but set minimums for important memory pools <br />Result set cache is promising, but right now is of limited applicability<br />
  35. 35. End of Presentation<br />