8 Copyright © 2006, Oracle. All rights reserved. Tuning the Shared Pool.

Slides:



Advertisements
Similar presentations
Office of the Accountant General (A&E) Andhra Pradesh Hyderabad
Advertisements

9 Copyright © 2006, Oracle. All rights reserved. Automatic Performance Management.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
IO Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Waits Covered in this Section  db file sequential read  db file scattered.
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.
Buffer Cache Waits. #.2 Copyright 2006 Kyle Hailey Buffer Cache Waits Waits Disk I/O Buffer Busy Library Cache Enqueue SQL*Net Free Buffer Hot Blocks.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Oracle Architecture. Instances and Databases (1/2)
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
13 Copyright © 2005, Oracle. All rights reserved. Performance Management.
15 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Memory.
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
10 Copyright © 2006, Oracle. All rights reserved. Automatic Shared Memory Management.
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
13 Copyright © 2004, Oracle. All rights reserved. Oracle Shared Servers.
1 Copyright © 2009, Oracle. All rights reserved. Exploring the Oracle Database Architecture.
Shared Pool Waits. #.2 Copyright 2006 Kyle Hailey Shared Pool Waits  Library Cache Latch  Shared Pool Latch  Library Cache Pin  Library Cache Lock.
12 Copyright © 2004, Oracle. All rights reserved. Automatic Management.
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
2 Copyright © 2006, Oracle. All rights reserved. Performance Tuning: Overview.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle on Windows Server Introduction to Oracle10g on Microsoft Windows Server.
Basic Oracle Architecture
Oracle PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Chapter 20 Other Memory Management Topics
1 Using Statspack in Oracle8i and 9i to Identify Problems Ian Jones Database Specialists, Inc.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
The Persistence of Memory (Issues) Brian Hitchcock OCP 8, 8i, 9i DBA Sun Microsystems NoCOUG Brian Hitchcock April.
Oracle9i Performance Tuning Chapter 2 Tuning the Buffer Cache.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
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.
13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space.
Anton TopurovIT-DB 23 April 2013 Introduction to Oracle2.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
15 Copyright © 2006, Oracle. All rights reserved. Performance Tuning: Summary.
Achieving Scalability, Performance and Availability on Linux with Oracle 9iR2-RAC Grant McAlister Senior Database Engineer Amazon.com Paper
1 06/05/08 Statspack Kyle Hailey
Outline Introduction to Oracle Memory Structures SGA, PGA, SCA The Specifics of the System Global Area (SGA) Structures Overview of Program Global Areas.
Instance and Media Recovery Structures Supinfo Oracle Lab. 7.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
3 Copyright © 2006, Oracle. All rights reserved. Statistics and Wait Events.
Preface 1Performance Tuning Methodology: A Review Course Structure 1-2 Lesson Objective 1-3 Concepts 1-4 Determining the Worst Bottleneck 1-5 Understanding.
E Copyright © 2006, Oracle. All rights reserved. Oracle Shared Servers.
7 Copyright © Oracle Corporation, All rights reserved. Instance and Media Recovery Structures.
5 Copyright © Oracle Corporation, All rights reserved. Usage and Configuration of the Oracle Shared Server.
Oracle9i Performance Tuning Chapter 4 Tuning the Shared Pool Memory.
Usage and Configuration of the Oracle Shared Server Supinfo Oracle Lab. 5.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
5 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
Oracle Database Architectural Components
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
SQL Statement Processing
Oracle Memory Internals
Troubleshooting Techniques(*)
Oracle Architectural Components
Index Index.
Database administration
Presentation transcript:

8 Copyright © 2006, Oracle. All rights reserved. Tuning the Shared Pool

8-2 Copyright © 2006, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Diagnose shared pool problems Size the shared pool Size the reserved area Keep objects in the shared pool

8-3 Copyright © 2006, Oracle. All rights reserved. Shared Pool Architecture Major components of the shared pool are: Library cache Data dictionary cache User global area (UGA) for shared server sessions Database buffer cache Redo log buffer Shared pool Library cache Data dictionary cache Shared areas Large pool UGA

8-4 Copyright © 2006, Oracle. All rights reserved. Shared Pool Operation The shared pool is managed by an LRU algorithm. New objects require memory allocations. Re-creatable objects are aged out of the cache. Objects are made up of chunks of memory. A memory allocation is a whole chunk. A chunk is contiguous.

8-5 Copyright © 2006, Oracle. All rights reserved. The Library Cache Stores complex object metadata associated with cursors Stores SQL statements and PL/SQL blocks that are to be shared by users Prevents statement reparsing

8-6 Copyright © 2006, Oracle. All rights reserved. SQLAREA SQL and PL/SQL Storage Cursor context area for SELECT statement 2 Cursor context area for SELECT statement 1 Shared pool SELECT statement 2 SELECT statement 1 SELECT statement 1

8-7 Copyright © 2006, Oracle. All rights reserved. Cursor Usage and Parsing Parse procedure: 1.Find and execute an open cursor. 2.Find a closed cursor in the session cache. 3.Search the hash chains (soft parse). 4.Construct the cursor (hard parse). Open cursors Closed cursors Session memory (UGA)Shared pool (SGA) Cursor handles Hash chains

8-8 Copyright © 2006, Oracle. All rights reserved.

8-9 Copyright © 2006, Oracle. All rights reserved. Important Shared Pool Latches latch : shared pool protects memory allocations in the shared pool. latch : library cache locates matching SQL in the shared pool.

8-10 Copyright © 2006, Oracle. All rights reserved. Mutex A mutual exclusion object allows: Sharing of a resource without corruption Shared access for reads Exclusive access for update Each object to have its own mutex

8-11 Copyright © 2006, Oracle. All rights reserved. Benefits of Mutex Performance is improved with mutexes. Mutexes: Are smaller and faster Have less potential for contention Replace latches and pins

8-12 Copyright © 2006, Oracle. All rights reserved.

8-13 Copyright © 2006, Oracle. All rights reserved. Mutex Views and Statistics Mutex views: – V$MUTEX_SLEEP – V$MUTEX_SLEEP_HISTORY Mutex wait events: – cursor:mutex X – cursor:mutex S – cursor:pin X – cursor:pin S – cursor:pin S wait on X

8-14 Copyright © 2006, Oracle. All rights reserved.

8-15 Copyright © 2006, Oracle. All rights reserved. Mutex-Protected Operations From onward, mutex protects: Selects from V$SQLSTAT Searches of child cursor lists

8-16 Copyright © 2006, Oracle. All rights reserved. Statspack/AWR Indicators Statspack and AWR reports include indicators: Load Profile Instance Efficiencies Top Wait Events Time Model

8-17 Copyright © 2006, Oracle. All rights reserved. Load Profile Load Profile Per Second Per Transaction ~~~~~~~~~~~~ User calls: Parses: Hard parses: % Blocks changed per Read: 0.18 Recursive Call %: Rollback per transaction %: 9.76 Rows per Sort: 8.47

8-18 Copyright © 2006, Oracle. All rights reserved. Instance Efficiencies Instance Efficiency Percentages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Buffer Nowait %: Redo NoWait %: Buffer Hit %: In-memory Sort %: Library Hit %: Soft Parse %: Execute to Parse %: Latch Hit %: Parse CPU to Parse Elapsd %: % Non-Parse CPU: Shared Pool Statistics Begin End Memory Usage %: % SQL with executions>1: % Memory for SQL w/exec>1:

8-19 Copyright © 2006, Oracle. All rights reserved. Top Waits Top 5 Timed Events Avg %Total ~~~~~~~~~~~~~~~~~~ wait Call Event Waits Time (s) (ms) Time CPU time latch: library cache latch: shared pool db file sequential read 1, log file parallel write

8-20 Copyright © 2006, Oracle. All rights reserved. Time Model Time Model System Stats -> Ordered by % of DB time desc, Statistic name % of Statistic Time (s) DB time sql execute elapsed time DB CPU parse time elapsed hard parse elapsed time PL/SQL compilation elapsed time PL/SQL execution elapsed time connection management call elapsed failed parse elapsed time hard parse (sharing criteria) elaps sequence load elapsed time hard parse (bind mismatch) elapsed repeated bind elapsed time DB time 417.9

8-21 Copyright © 2006, Oracle. All rights reserved.

8-22 Copyright © 2006, Oracle. All rights reserved. Library Cache Activity Library Cache Activity DB/Inst: ORCL/orcl Snaps: >"Pct Misses" should be very low Get Pct Pin Pct Invali- Namespace Requests Miss Requests Miss Reloads dations BODY CLUSTER INDEX , SQL AREA 18, ,

8-23 Copyright © 2006, Oracle. All rights reserved. Terminology Gets: (Parse) The number of lookups for objects of the namespace Pins: (Execution) The number of reads or executions of the objects of the namespace Reloads: (Parse) The number of library cache misses on the execution step, thereby causing an implicit reparsing of the SQL statement Invalidations: The number of times an object is modified by a DDL, causing all dependent objects to be marked invalid

8-24 Copyright © 2006, Oracle. All rights reserved. V$SGASTAT V$SGAINFO V$LIBRARYCACHE V$LIBRARY_CACHE_MEMORY V$SHARED_POOL_RESERVED V$SQLSTATS V$SQL V$SQLAREA V$SQLTEXT V$DB_OBJECT_CACHE Diagnostic Tools for Tuning the Shared Pool Parameters affecting the components: SHARED_POOL_SIZE, OPEN_CURSORS SESSION_CACHED_CURSORS, CURSOR_SPACE_FOR_TIME CURSOR_SHARING, SHARED_POOL_RESERVED_SIZE sp_m_n.lst report.txt Data dictionary cache Shared pool Library cache Shared SQL and PL/SQL Views

8-25 Copyright © 2006, Oracle. All rights reserved.

8-26 Copyright © 2006, Oracle. All rights reserved. Library Cache Reloads Reloads should be less than 1% of the pins: If the reloads-to-pins ratio is greater than 1%, increase the value of the SHARED_POOL_SIZE parameter. SQL> SELECT SUM(pins) "Executions", 2 SUM(reloads) "Cache Misses", 3 SUM(reloads)/SUM(pins) 4 FROM V$LIBRARYCACHE; Executes PROC1 — > 1st pin, 1 load Executes PROC1 — > 2nd pin, no reload Executes PROC1 — > 3rd pin, no reload Executes PROC1 — > 4th pin, no reload Four pins and no reloads

8-27 Copyright © 2006, Oracle. All rights reserved. Invalidations The number of times objects of the namespace were marked invalid, causing reloads: SQL> SELECT COUNT(*) FROM hr.employees; SQL> SELECT namespace,pins,reloads, 2 invalidations 3 FROM V$LIBRARYCACHE; SQL> execute DBMS_STATS.GATHER_TABLE_STATS - > ('HR','EMPLOYEES'); SQL> SELECT COUNT(*) FROM hr.employees; SQL> SELECT namespace,pins,reloads, 2 invalidations 3 FROM V$LIBRARYCACHE;

8-28 Copyright © 2006, Oracle. All rights reserved.

8-29 Copyright © 2006, Oracle. All rights reserved. Avoid Hard Parses In an OLTP system, reduce misses by keeping hard parsing to a minimum: Make sure that users can share statements. Prevent frequently used statements from being aged out by allocating enough space. Avoid invalidations that induce reparsing.

8-30 Copyright © 2006, Oracle. All rights reserved. Are Cursors Being Shared? Check GETHITRATIO in V$LIBRARYCACHE : Determine which statements could be shared: SQL> SELECT plan_hash_value, count(*) 2 FROM V$SQL 3 GROUP BY plan_hash_value ORDER BY 2 DESC SQL> SELECT sql_text, executions 2 FROM V$SQLAREA 3 WHERE plan_hash_value = NNNNNNNNN SQL> SELECT gethitratio 2 FROM V$LIBRARYCACHE 3 WHERE namespace = 'SQL AREA';

8-31 Copyright © 2006, Oracle. All rights reserved.

8-32 Copyright © 2006, Oracle. All rights reserved. Sharing Cursors Values for CURSOR_SHARING are: EXACT SIMILAR FORCE

8-33 Copyright © 2006, Oracle. All rights reserved. Avoiding Soft Parses Reducing soft parses reduces library cache latch contention. Keep soft parsing to a minimum by: –Setting SESSION_CACHED_CURSORS –Setting HOLD_CURSOR in the application precompiler –Setting CURSOR_SPACE_FOR_TIME

8-34 Copyright © 2006, Oracle. All rights reserved. Avoiding Fragmentation Avoid fragmentation by: Upgrading to x Keeping frequently required large objects Reserving space for large objects Eliminating large anonymous PL/SQL blocks Enabling the use of large pool

8-35 Copyright © 2006, Oracle. All rights reserved. Sizing the Shared Pool Use Automatic Shared Memory Management. Use the Shared Pool Advisor and confirm using other diagnostics when data has operational history. Use 40 percent of the SGA size to start, when there is no history. Monitor and adjust as needed. Do not increase the size when free memory is available. SQL> SELECT * FROM V$SGASTAT 2 WHERE NAME = 'free memory' 3 AND POOL = 'shared pool';

8-36 Copyright © 2006, Oracle. All rights reserved. Shared Pool Advisory SQL> SELECT shared_pool_size_for_estimate AS 2 pool_size, estd_lc_size, 3 estd_lc_time_saved 4 FROM V$SHARED_POOL_ADVICE; POOL_SIZE ESTD_LC_SIZE ESTD_LC_TIME_SAVED

8-37 Copyright © 2006, Oracle. All rights reserved.

8-38 Copyright © 2006, Oracle. All rights reserved. Shared Pool Advisor

8-39 Copyright © 2006, Oracle. All rights reserved. Large Memory Requirements Satisfy requests for large contiguous memory. Reserve contiguous memory within the shared pool. SHARED_POOL_SIZE SHARED_POOL_RESERVED_SIZE Data dictionary cache Shared pool Library cache Shared SQL and PL/SQL V$SHARED_POOL_RESERVED Reserved area

8-40 Copyright © 2006, Oracle. All rights reserved.

8-41 Copyright © 2006, Oracle. All rights reserved. Tuning the Shared Pool Reserved Space IF REQUEST_FAILURES Action >0 and increasingANDRequest_misses > 0 Increase SHARED_POOL_ RESERVED_SIZE >0 and increasingAND Free_memory => 50% of SHARED_POOL_RESERVE D_SIZE Increase SHARED_POOL_ SIZE =0ORFree_memory => 50% of SHARED_POOL_RESERVE D_SIZE Decrease SHARED_POOL_ RESERVED_SIZE

8-42 Copyright © 2006, Oracle. All rights reserved.

8-43 Copyright © 2006, Oracle. All rights reserved. Keeping Large Objects Find those PL/SQL objects that are not kept in the library cache: Pin large packages in the library cache: SQL> EXECUTE DBMS_SHARED_POOL.KEEP(‘package_name’); SQL> SELECT * FROM V$DB_OBJECT_CACHE 2 WHERE sharable_mem > AND (type='PACKAGE' OR type='PACKAGE BODY' OR 4 type='FUNCTION' OR type='PROCEDURE') 5 AND kept='NO';

8-44 Copyright © 2006, Oracle. All rights reserved.

8-45 Copyright © 2006, Oracle. All rights reserved. Data Dictionary Cache The data dictionary cache holds row images of data dictionary rows. Data dictionary cache Data dictionary

8-46 Copyright © 2006, Oracle. All rights reserved. Statspack/AWR report output: If there are too many cache misses, increase the SHARED_POOL_SIZE parameter. Dictionary Cache Misses Get Pct Final Cache Requests Miss Usage dc_histogram_data 5, dc_histogram_defs 92, dc_object_grants dc_object_ids 959, dc_objects 19,

8-47 Copyright © 2006, Oracle. All rights reserved. UGA and Oracle Shared Server Shared pool PGA Shared pool or Large pool Stack space PGA Stack space User session data Cursor state UGA V$STATNAME V$SESSTAT V$MYSTAT OPEN_CURSORS SESSION_CACHED_CURSORS Cursor state User session data UGA Dedicated server configuration Shared server configuration

8-48 Copyright © 2006, Oracle. All rights reserved. Shared pool Library cache Data dictionary cache UGA Database buffer cache Redo log buffer Large pool Large Pool Can be configured as a separate memory area in the SGA, used for memory with: –I/O server processes: DBWR_IO_SLAVES –Backup and restore operations –Session memory for the shared servers –Parallel query messaging Is used to avoid performance overhead caused by shrinking the shared SQL cache Is sized by the LARGE_POOL_SIZE parameter

8-49 Copyright © 2006, Oracle. All rights reserved. Tuning the Large Pool The large pool has one parameter, LARGE_POOL_SIZE. V$SGASTAT shows used and free memory. SELECT * FROM V$SGASTAT WHERE pool = 'large pool'; POOL NAME BYTES large pool free memory large pool session heap

8-50 Copyright © 2006, Oracle. All rights reserved. Practice Overview: Tune the Shared Pool This practice covers the following topics: Tune a hard parse workload Tune a soft parse workload Keep objects in the shared pool

8-51 Copyright © 2006, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Diagnose shared pool problems Size the shared pool Size the reserved area Keep objects in the shared pool

8-52 Copyright © 2006, Oracle. All rights reserved.