Caching for PL/SQL Performance Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCA.

Slides:



Advertisements
Similar presentations
PL/SQL : Stop making the same performance mistakes
Advertisements

Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Database Performance Tuning and Query Optimization
Copyright © 200\8 Quest Software High Performance PL/SQL Guy Harrison Chief Architect, Database Solutions.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
15 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Memory.
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
Harvard University Oracle Database Administration Session 5 Data Storage.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Oracle 10g Database Administrator: Implementation and Administration Chapter 14 Proactive Maintenance.
Bruce Armstrong TeamSybase
PL/SQL Bulk Collections in Oracle 9i and 10g Kent Crotty Burleson Consulting October 13, 2006.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
11g New Features for PL/SQL Developers Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g,
15 Copyright © 2004, Oracle. All rights reserved. Proactive Maintenance.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
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 PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
1 Oracle Database 11g – Flashback Data Archive. 2 Data History and Retention Data retention and change control requirements are growing Regulatory oversight.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Chapter 20 Other Memory Management Topics
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 7 PL/SQL Packages.
The Self-Managing Database: Guided Application and SQL Tuning Mohamed Ziauddin Consulting Member of Technical Staff Oracle Corporation Session id:
Oracle Application Express Security. © 2009 Oracle Corporation Authentication Out-of-the-Box Pre-Configured Schemes LDAP Directory credentials Oracle.
RBO RIP George Lumpkin Director Product Management Oracle Corporation Session id:
1 Chapter 7 Optimizing the Optimizer. 2 The Oracle Optimizer is… About query optimization Is a sophisticated set of algorithms Choosing the fastest approach.
From Zero to Hero : Using an assortment of caching techniques to improve performance of SQL containing PL/SQL calls. Tim Hall.
Oracle Database 11g’s Result Cache Rob van Wijk 28 October 2010.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 6 Functions.
PL/SQLPL/SQL Oracle11g : PL/SQL Programming Chapter 6 Functions.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Using Procedures & Functions Oracle Database PL/SQL 10g Programming Chapter 9.
The Self-Managing Database: Automatic SGA Memory Management Tirthankar Lahiri Senior Manager, Distributed Cache & Memory Management Oracle Corporation.
Outline Introduction to Oracle Memory Structures SGA, PGA, SCA The Specifics of the System Global Area (SGA) Structures Overview of Program Global Areas.
1 Chapter 17 Shared Memory Contention. 2 Overview Specifically talking about SGA – Buffer Cache – Redo Log Buffer Contention in these areas of SGA – Can.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
Session id: Darrell Hilliard Senior Delivery Manager Oracle University Oracle Corporation.
Oracle9i Performance Tuning Chapter 11 Advanced Tuning Topics.
Oracle9i Performance Tuning Chapter 4 Tuning the Shared Pool Memory.
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Oracle9i Developer: PL/SQL Programming Chapter 5 Functions.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
16 Copyright © 2007, Oracle. All rights reserved. Miscellaneous New Features.
5 Copyright © 2007, Oracle. All rights reserved. Implementing the Performance Improvements.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Oracle9i Developer: PL/SQL Programming Chapter 6 PL/SQL Packages.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Tim Hall Oracle ACE Director
Database Performance Tuning &
The powerhouse PL/SQL upgrade option: Edition-Based Redefinition (EBR)
Oracle 1Z0-148 Questions Answers VCE
1Z0-148 Dumps Oracle Database 12c: Advanced PL/SQL Exam Just 1 day study required to pass exam 100% Passing Assurance.
Reading Execution Plans Successfully
Steve Hood SimpleSQLServer.com
Reading Execution Plans Successfully
Presentation transcript:

Caching for PL/SQL Performance Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCA PL/SQL Developer Oracle PL/SQL Tuning (Rampant) Oracle Job Scheduling (Rampant)

Caching for PL/SQL Performance Using arrays for lookup tables.Using arrays for lookup tables. Cross-Session PL/SQL Function Result CacheCross-Session PL/SQL Function Result Cache Query Result CacheQuery Result Cache

Using arrays for lookup tables Many systems have lots of small lookup tables.Many systems have lots of small lookup tables. Most of these lookup tables contain static data.Most of these lookup tables contain static data. Data loads/extracts often access lookup tables for each row processed.Data loads/extracts often access lookup tables for each row processed. The overhead of these static lookups can be reduce significantly by caching the data in associative arrays.The overhead of these static lookups can be reduce significantly by caching the data in associative arrays. setup.sqlsetup.sqlsetup.sql lookup_api.sqllookup_api.sqllookup_api.sql lookup_test.sqllookup_test.sqllookup_test.sql Using other collection types doesn’t work so well.Using other collection types doesn’t work so well. lookup_api_incorrect.sqllookup_api_incorrect.sqllookup_api_incorrect.sql lookup_test.sqllookup_test.sqllookup_test.sql

Considerations when caching data Data Volatility – Only cache static data, or data you expect to be static during the lifetime of your process. *Data Volatility – Only cache static data, or data you expect to be static during the lifetime of your process. * Memory Usage – Collections are held in memory, so lots of cached tables will waste lots of memory. Also, the caching is session-specific, so lots of sessions means lots of memory used. *Memory Usage – Collections are held in memory, so lots of cached tables will waste lots of memory. Also, the caching is session-specific, so lots of sessions means lots of memory used. * Initialization Time – The data must be cached before processing starts, which takes time. *Initialization Time – The data must be cached before processing starts, which takes time. * * - Clever implementation can offset some of these issues.* - Clever implementation can offset some of these issues. Lookup Type – This method is restricted to lookups using a single “index” column. Prior to 9i R2, it is limited to number based indexes.Lookup Type – This method is restricted to lookups using a single “index” column. Prior to 9i R2, it is limited to number based indexes. Bad Implementation – Test to make sure you are actually seeing improvements.Bad Implementation – Test to make sure you are actually seeing improvements.

PL/SQL Function Result Cache The cross-session PL/SQL function result cache boosts the performance of PL/SQL functions by caching results in the SGA.The cross-session PL/SQL function result cache boosts the performance of PL/SQL functions by caching results in the SGA. The cache is accessible to any session calling the same function with the same parameters.The cache is accessible to any session calling the same function with the same parameters. Caching clause results in significant performance improvements when functions are called for each row in an SQL query, or within a loop in PL/SQL.Caching clause results in significant performance improvements when functions are called for each row in an SQL query, or within a loop in PL/SQL. The RESULT_CACHE clause indicates a function is available for caching.The RESULT_CACHE clause indicates a function is available for caching. pfrc_setup.sql & pfrc_test.sqlpfrc_setup.sql & pfrc_test.sqlpfrc_setup.sqlpfrc_test.sqlpfrc_setup.sqlpfrc_test.sql The optional RELIES_ON clause is used to specify dependent tables and views so the result cache can be invalidated if the dependent objects are modified.The optional RELIES_ON clause is used to specify dependent tables and views so the result cache can be invalidated if the dependent objects are modified. relies_on.sql & pfrc_test.sqlrelies_on.sql & pfrc_test.sqlrelies_on.sqlpfrc_test.sqlrelies_on.sqlpfrc_test.sql Performance improvements depend on the nature of the work being done.Performance improvements depend on the nature of the work being done.

SQL Result Cache The query result cache stores the result of queries in the SGA.The query result cache stores the result of queries in the SGA. The cache is accessible to any session calling the same query.The cache is accessible to any session calling the same query. The RESULT_CACHE hint indicates the results of a query should be cached.The RESULT_CACHE hint indicates the results of a query should be cached. qrc_setup.sql, qrc_test_1.sql & qrc_test_2.sqlqrc_setup.sql, qrc_test_1.sql & qrc_test_2.sqlqrc_setup.sqlqrc_test_1.sqlqrc_test_2.sqlqrc_setup.sqlqrc_test_1.sqlqrc_test_2.sql The result cache is controlled by the RESULT_CACHE_MODE parameter. Settings:The result cache is controlled by the RESULT_CACHE_MODE parameter. Settings: –MANUAL – (default) Query must include the RESULT_CACHE hint to be cached. –FORCE – Caching can be prevented using the NO_RESULT_CACHE hint. qrc_force.sqlqrc_force.sqlqrc_force.sql

Cache Administration The query result cache and PL/SQL Function result cache use same result cache memory pool.The query result cache and PL/SQL Function result cache use same result cache memory pool. The pool is configured using the RESULT_CACHE_% parameters.The pool is configured using the RESULT_CACHE_% parameters. rc_params.sqlrc_params.sqlrc_params.sql –result_cache_mode - MANUAL or FORCE control what and how caching takes place. –result_cache_max_size - Amount of SGA used for the cache. Zero disables the feature. –result_cache_max_result - The percentage of total cache any single query can use. –result_cache_remote_expiration - The number of minutes remote objects remain valid. Zero means remote objects are not cached.

Cache Administration The DBMS_RESULT_CACHE package provides some cache management (invalidations, flushing, bypass, memory usage).The DBMS_RESULT_CACHE package provides some cache management (invalidations, flushing, bypass, memory usage). Performance information about the cache is displayed using the V$RESULT_CACHE_% views.Performance information about the cache is displayed using the V$RESULT_CACHE_% views. rc_views.sqlrc_views.sqlrc_views.sql –V$RESULT_CACHE_DEPENDENCY - Displays dependencies between cached results and database objects. –V$RESULT_CACHE_MEMORY - Displays result cache memory usage. –V$RESULT_CACHE_OBJECTS - Displays attributes of cached results and dependencies. –V$RESULT_CACHE_STATISTICS - Displays various result cache settings and usage statistics. The result cache memory pool is part of the SGA, so you need free memory to make use of it.The result cache memory pool is part of the SGA, so you need free memory to make use of it.

Summary Caching lookup tables in arrays can improve performance for batch operations.Caching lookup tables in arrays can improve performance for batch operations. Manually caching volatile data is dangerous.Manually caching volatile data is dangerous. Caching data requires memory, so be careful.Caching data requires memory, so be careful. The query result cache and PL/SQL function cache automate caching for us in 11g.The query result cache and PL/SQL function cache automate caching for us in 11g. Always test to make sure the improvements are worth the effort!Always test to make sure the improvements are worth the effort! Example code:Example code: