Shared Pool Waits. #.2 Copyright 2006 Kyle Hailey Shared Pool Waits  Library Cache Latch  Shared Pool Latch  Library Cache Pin  Library Cache Lock.

Slides:



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

13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Memory.
Part IV: Memory Management
IO Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Waits Covered in this Section  db file sequential read  db file scattered.
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Wait Tree - Locks Waits Disk I/O Library Cache Enqueue Undo TX 6 Row Lock TX 4 ITL Lock HW Lock.
Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Locks REDO Lib Cache Buffer Cache IO Locks Network.
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Shared Pool Waits. #.2 Copyright 2006 Kyle Hailey Shared Pool Waits 1.Latch: Library Cache 2.Latch: Shared Pool Latch 3.Library Cache Pin 4.Library Cache.
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.
Copyright © 200\8 Quest Software High Performance PL/SQL Guy Harrison Chief Architect, Database Solutions.
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.
19: Protection1 PROTECTION Protection is the mechanism for controlling access to computer resources. Security concerns the physical integrity of the system.
1 - Oracle Server Architecture Overview
Redo Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Log File Waits  Redo is written to disk when  User commits  Log Buffer.
Redo Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Redo REDO Lib Cache Buffer Cache Locks Network I/O.
Waits Events and the Geeks who love them Kyle Hailey
Waits Defined Kyle Hailey #.2 Copyright 2006 Kyle Hailey Top 36 Foreground Waits write complete waits library cache.
Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao ISBN: CMPBooks.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Part II : Waits Events Kyle Hailey
Chapter 20 Other Memory Management Topics
Exam2 Review Bernard Chen Spring Deadlock Example semaphores A and B, initialized to 1 P0 P1 wait (A); wait(B) wait (B); wait(A)
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
Copyright © 2013, SAS Institute Inc. All rights reserved. MEMORY CACHE – PERFORMANCE CONSIDERATIONS CLAIRE CATES DISTINGUISHED DEVELOPER
Oracle Locking Michael Messina Principal Database Analyst Indiana University.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
#.6 Sampling Kyle Hailey
Dynamic SQL. 2 home back first prev next last What Will I Learn? Recall the stages through which all SQL statements pass Describe the reasons for using.
Processes and Virtual Memory
Shared Pool Waits Kyle Hailey
Preface 1Performance Tuning Methodology: A Review Course Structure 1-2 Lesson Objective 1-3 Concepts 1-4 Determining the Worst Bottleneck 1-5 Understanding.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
Lecture 7 Page 1 CS 111 Summer 2013 Dynamic Domain Allocation A concept covered in a previous lecture We’ll just review it here Domains are regions of.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Oracle9i Performance Tuning Chapter 4 Tuning the Shared Pool Memory.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Cursor Sharing Bug: Bug : cursor_sharing=force causes ORA-7445 and core dumps related bugs – : production instance crashed with.
8 Copyright © 2006, Oracle. All rights reserved. Tuning the Shared Pool.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
Memory Management.
Memory Caches & TLB Virtual Memory
Protection of System Resources
CSI 400/500 Operating Systems Spring 2009
Hustle and Bustle of SQL Pages
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
SQL Statement Processing
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Oracle Memory Internals
CSE451 Virtual Memory Paging Autumn 2002
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
COMP755 Advanced Operating Systems
Inside the Database Engine
CSE 542: Operating Systems
Inside the Database Engine
Inside the Database Engine
Presentation transcript:

Shared Pool Waits

#.2 Copyright 2006 Kyle Hailey Shared Pool Waits  Library Cache Latch  Shared Pool Latch  Library Cache Pin  Library Cache Lock  Library Cache Load Lock  Row Cache Lock

#.3 Copyright 2006 Kyle Hailey Hash Table handle Shared Pool Structure

#.4 Copyright 2006 Kyle Hailey Shared Pool Latch  Protects Space Allocation in the Shared Pool  Make sure two users don’t get same chunk of memory

#.5 Copyright 2006 Kyle Hailey Bucket sizes 0 < 80 bytes 1 < < < < < < < < < bigger Shared Pool Latch Shared Pool pre Memory Chunk Buckets

#.6 Copyright 2006 Kyle Hailey Shared Pool Free Space Shared Pool Latch covers changes in the lists of free memory chunks Shared Pool Latch

#.7 Copyright 2006 Kyle Hailey Get library cache latch Get shared pool latch Search right bucket Find best fit => If lists get long, search gets long Shared Pool Latch

#.8 Copyright 2006 Kyle Hailey Shared Pool Free Space Shared Pool Latch

#.9 Copyright 2006 Kyle Hailey Shared Pool Memory Chunk Buckets and up 0 16 bytes 1 20 bytes … ( only have one chunk size in bucket ) bytes to 872 …. ( only have 16 possible chunk sizes per bucket ) bigger Shared Pool Latch

#.10 Copyright 2006 Kyle Hailey library cache pin and locks  Locks control access, protects handle  Pins guarentees coherency, protects heaps  To Access to a cursor  Lock handle  Locking is the way of locating  Pin  Pinning loads any necessary heaps  Guarenteed to stay in memory until pin is released handle pin lock Heap 1 Child cursor 1 Heap 6 Heap 0

#.11 Copyright 2006 Kyle Hailey library cache lock and pins   Contention when Sessions try to load/compile same SQL at same time   Locks and Pins are usually in share mode unless modifications are being made

#.12 Copyright 2006 Kyle Hailey library cache lock handle pin lock   #20   P1 = address of object   P2 = address of lock   P3 = mode | namespace   See x$kgllk

#.13 Copyright 2006 Kyle Hailey library cache pin  #13  P1 = address of object  P2 = address of lock  P3 = Mode | Namespace  See x$kglpn handle pin lock

#.14 Copyright 2006 Kyle Hailey Solutions  Have only one Session compile a the same cursor at a time  Waits – find “competing” Sessions

#.15 Copyright 2006 Kyle Hailey SQL: Lib Cache Lock Find the waiters and who blocks them column wevent format a20 column bevent format a20 select waiter.sid waiter, waiter.p1raw wlockp1, waiter.event wevent, blocker_event.sid blocker, blocker_event.event bevent from x$kglpn p, gv$session blocker_session, gv$session_wait waiter, gv$session_wait blocker_event where p.kglpnuse=blocker_session.saddr and p.kglpnhdl=waiter.p1raw and (waiter.event like 'library cache lock' ) and blocker_event.sid=blocker_session.sid order by waiter.p1raw,waiter.sid /

#.16 Copyright 2006 Kyle Hailey library cache load lock  #23  Waiting For a Reload by another Session

#.17 Copyright 2006 Kyle Hailey Library Cache Latch  Protects changes in Library Cache  Library Locks are not atomic  Thus need library cache latch  Broken out into  library cache pin allocation  library cache lock allocation  library cache lock  library cache  library cache pin  library cache load lock

#.18 Copyright 2006 Kyle Hailey Hash Table handle pin lock Library Cache handle Find and Lock Pin (and Load)

#.19 Copyright 2006 Kyle Hailey Child cursor 3 Hash Table handle Cursor (0) pin lock Heap 1 Child cursor 1 Child cursor 2 Heap 6 pin lock Heap 0 pin lock waiters holders Handle Cursor(0) flags Library Cache Structures Library Cache Latch

#.20 Copyright 2006 Kyle Hailey Library Cache Latch Contention  Excesive Hard Parsing  Not Sharing SQL – use of Literal Values  Shared Pool too small  Too many invalidations  Excessive Soft Parsing

#.21 Copyright 2006 Kyle Hailey Sharing SQL & Literals PLAN_HASH_VALUE CNT SQL_TEXT SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= SELECT * FROM dual WHERE dummy= select plan_hash_value, plan_hash_value,count(plan_hash_value)fromv$sql group by plan_hash_value, order by count(plan_hash_value) select plan_hash_value, plan_hash_value,count(plan_hash_value)fromv$sql group by plan_hash_value, order by count(plan_hash_value) select sql_text from v$sql where plan_hash_value = and rownum < 10; select sql_text from v$sql where plan_hash_value = and rownum < 10;

#.22 Copyright 2006 Kyle Hailey Cursor Sharing  Bind Variables  Select * from dual where dummy = :var;  Cursor_Sharing  Cursor_sharing = Force Oracle replaces variables with bind variables  Defaults to Exact

#.23 Copyright 2006 Kyle Hailey Shared Pool too Small  Reloads means Cursor heaps were kicked out implying shared_pool too small SQL> select namespace, reloads from v$librarycache; from v$librarycache; NAMESPACE RELOADS SQL AREA 367 TABLE/PROCEDURE 592 SQL> select namespace, reloads from v$librarycache; from v$librarycache; NAMESPACE RELOADS SQL AREA 367 TABLE/PROCEDURE 592

#.24 Copyright 2006 Kyle Hailey Invalidations  Changes in dependent objects invalidate cursor FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor, 'SELECT * FROM toto',dbms_sql.native); execute immediate 'analyze table toto compute statistics'; dbms_sql.close_cursor(l_cursor); END LOOP; SQL> select namespace, invalidations invalidations from v$librarycache; from v$librarycache; NAMESPACE INVALIDATIONS SQL AREA 6065 SQL> select namespace, invalidations invalidations from v$librarycache; from v$librarycache; NAMESPACE INVALIDATIONS SQL AREA 6065

#.25 Copyright 2006 Kyle Hailey Re-Executing a Cursor 1.Libray Cache latch 2.Locks 3.Pins pin lock Execute 1Execute 2Execute 3Execute 4Execute 5 Cursor Memory lock = Latch Soft Parsing

#.26 Copyright 2006 Kyle Hailey Session Cached Cursors Execute 1Execute 2Execute 3Execute 4Execute 5 Cursor Memory lock = Latch pin Session_cached_cursor: If Opening/Closing keeps locked in Memory

#.27 Copyright 2006 Kyle Hailey Session Cached Cursors FOR i IN LOOP FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'SELECT * FROM dual’,dbms_sql.native); dbms_sql.parse(l_cursor,'SELECT * FROM dual’,dbms_sql.native); dbms_sql.close_cursor(l_cursor); dbms_sql.close_cursor(l_cursor); END LOOP; END LOOP; FOR i IN LOOP FOR i IN LOOP l_cursor:=dbms_sql.open_cursor; l_cursor:=dbms_sql.open_cursor; dbms_sql.parse(l_cursor,'SELECT * FROM dual’,dbms_sql.native); dbms_sql.parse(l_cursor,'SELECT * FROM dual’,dbms_sql.native); dbms_sql.close_cursor(l_cursor); dbms_sql.close_cursor(l_cursor); END LOOP; END LOOP; Session_cached_cursors=0 Latch Gets library cache lock 120,028 library cache 180,074 library cache pin 60,048 Session_cached_cursors=20 library cache lock 4 library cache 60,061 library cache pin 60,048

#.28 Copyright 2006 Kyle Hailey Cursor Space for Time Execute 1Execute 2Execute 3Execute 4Execute 5 Cursor Memory Cursor_space_for_time=true : if open and re-executing – keeps cursor pinned (Cursor already locked because cursor is kept open) = Latch pin lock OpenCursor CloseCursor

#.29 Copyright 2006 Kyle Hailey Cursor Space For Time FOR i IN LOOP rc:=dbms_sql.execute(l_cursor); rc:=dbms_sql.execute(l_cursor); IF DBMS_SQL.FETCH_ROWS (l_cursor) < 0 THEN IF DBMS_SQL.FETCH_ROWS (l_cursor) < 0 THEN DBMS_SQL.COLUMN_VALUE (l_cursor, 1, cnt); DBMS_SQL.COLUMN_VALUE (l_cursor, 1, cnt); end if; end if; FOR i IN LOOP rc:=dbms_sql.execute(l_cursor); rc:=dbms_sql.execute(l_cursor); IF DBMS_SQL.FETCH_ROWS (l_cursor) < 0 THEN IF DBMS_SQL.FETCH_ROWS (l_cursor) < 0 THEN DBMS_SQL.COLUMN_VALUE (l_cursor, 1, cnt); DBMS_SQL.COLUMN_VALUE (l_cursor, 1, cnt); end if; end if; Cursor_space_for_time=false Latch Gets library cache lock 35 library cache 60,096 library cache pin 60,044 Cursor_space_for_time=true library cache lock 30 library cache 85 library cache pin 42

#.30 Copyright 2006 Kyle Hailey Efficient Lock and Pinning  Reduce use of latches  Improve throughput  Improve Concurrency ***

#.31 Copyright 2006 Kyle Hailey row cache lock : args  P1 = cache#  P2 = Lock Mode Held  P3 = Lock Mode Requested select parameter as “name” from v$rowcache where cache# = P1; select parameter as “name” from v$rowcache where cache# = P1;

#.32 Copyright 2006 Kyle Hailey Summary  Shared Pool Latch  Shard pool too small or too much hard pasing  Loading Same Cursor  Library Cache Pin  Library Cache Lock  Library Cache Load Lock  Library Cache Latch  Too much hard or soft parsing  Row Cache Lock

#.33 Copyright 2006 Kyle Hailey Library Cache Latch Solutions  Share Cursors  Use bind variables  User cursor_sharing=force  Avoid invalidations and reloads  Size shared_pool large enough  Avoid changing dependent objects  Soft Parsing  Session_cached_cursors =20 : keep across open/close  Cursor_space_for_time=true : keep pinned across executes  hold_cursor=true : used in precompilers