SlideShare a Scribd company logo
http://www.oracle-base.com
Improving the Performance of PL/SQL Function
Calls from SQL
Tim Hall
Oracle ACE Director
Oracle ACE of the Year 2006
OakTable Network
OCP DBA (7, 8, 8i, 9i, 10g, 11g)
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
http://www.oracle-base.com
Books
Oracle PL/SQL Tuning
Oracle Job Scheduling
http://www.oracle-base.com
What’s the problem?
 We sometimes need to call PL/SQL functions in the select list of
queries.
 By default, the function may be called for each row returned.
 If the function is called repeatedly with the same input parameters, this
can represent a massive waste of resources.
 Sometimes we are able to change the query, but not the
function. Sometimes we can change the function, but
not the query.
(setup.sql)
http://www.oracle-base.com
Scalar Subquery Caching
 Rewriting function calls as scalar subqueries allows Oracle to
cache the results.
SELECT (SELECT slow_function(id) FROM dual)
FROM func_test;
 Oracle sets up an in-memory hash table to cache results of scalar
subqueries.
 The cache only last for the lifetime of the query.
 The cached values are not reusable in the current
session or in other sessions.
 (scalar.sql)
http://www.oracle-base.com
DETERMINISTIC Hint
 The DETERMINISTIC hint has been available for a long time, but didn’t
seem to do much until 10g.
 Oracle will optimize calls to functions marked as DETERMINISTIC to
improve query performance.
 The caching is based on the array size of fetch, so mileage can vary.
 Cached return values only last for the lifetime of the call.
 The cached values are not reusable in the current session
or in other sessions.
 (deterministic.sql)
http://www.oracle-base.com
11g Result Cache
 11g introduced two new caching features.
 Both share the same pool of memory in the SGA, controlled using:
 RESULT_CACHE_% parameters.
 DBMS_RESULT_CACHE package.
 V$RESULT_CACHE_% views.
(result_cache.sql)
 The Query Result Cache improves performance of complex queries that
return small number of rows. (query_result_cache.sql)
 The Cross-Session PL/SQL Function Result Cache improves
performance of function calls by caching the return values.
(plsql_result_cache.sql)
 Cached results can be reused in the same session and
in other sessions.
http://www.oracle-base.com
Manual Caching Using PL/SQL Collections
 Caching of function calls is nothing new.
 Caching using PL/SQL collections has been done for many years.
 Collections are session-specific, but cached values can be reused in
multiple queries.
 (collection.sql)
 Manually caching can cause problems for volatile data.
 Remember, collections use memory. Don’t go nuts!
http://www.oracle-base.com
Manual Caching Using Contexts
 Manual caching using contexts is similar to using collections.
 It shares many of the same drawbacks, but can allow a shared cache
between sessions.
 (context.sql)
http://www.oracle-base.com
Scalar Subquery Caching (Revisited)
 Q: Do other caching methods make scalar subquery caching irrelevant?
 A: No. Alternative caching mechanisms don’t reduce context switching
between SQL and PL/SQL.
 (plsql_result_cache_2.sql)
 You should always use scalar subquery caching, even
when using other caching mechanisms.
 Scalar Subquery Caching reduces context switches,
but other methods have added benefits reuse
between queries and sessions.
http://www.oracle-base.com
Is there anything relevant in 12c?
 Functions (and procedures) in the WITH clause. Reduces the context
switching associated with PL/SQL calls, which improves performance.
WITH
FUNCTION slow_function(p_id IN NUMBER) IS
BEGIN
RETURN p_id;
END slow_function;
SELECT slow_function(id)
FROM test_func;
http://www.oracle-base.com
What about the FROM and WHERE clause?
 Function calls in the select list of an inline view follow the same rules as
for the main select list.
 If you are using table functions, consider switching to pipelined table
functions.
 Use Scalar Subquery Caching for functions in the WHERE clause if
possible.
 Avoid functions on indexed columns, or consider
function-based indexes.
(fbi.sql)
http://www.oracle-base.com
What did we cover?
 Scalar Subquery Caching
 DETERMINISTIC Hint
 Cross-Session PL/SQL Function Result Cache
 Manual Caching Using PL/SQL Collections
 Manual Caching Using Contexts
 Function calls in the FROM and WHERE clause
http://www.oracle-base.com
The End…
 Slides and Demos:
http://www.oracle-base.com/workshops
 Questions?

More Related Content

What's hot

Flashback - The Time Machine..
Flashback - The Time Machine..Flashback - The Time Machine..
Flashback - The Time Machine..
Navneet Upneja
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Oracle flashback
Oracle flashbackOracle flashback
Oracle flashback
Cambodia
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
Steven Feuerstein
 
Oracle 12c New Features for Developers
Oracle 12c New Features for DevelopersOracle 12c New Features for Developers
Oracle 12c New Features for Developers
CompleteITProfessional
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
baabtra.com - No. 1 supplier of quality freshers
 
High Performance Plsql
High Performance PlsqlHigh Performance Plsql
High Performance Plsql
Guy Harrison
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
rehaniltifat
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
rehaniltifat
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependencies
rehaniltifat
 
Oracle Flashback Query 3
Oracle Flashback Query 3Oracle Flashback Query 3
Oracle Flashback Query 3
grogers1124
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUC
Alex Zaballa
 
Oracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performansOracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performans
Emrah METE
 
Less17 flashback tb3
Less17 flashback tb3Less17 flashback tb3
Less17 flashback tb3
Imran Ali
 
Less08 managing data and concurrency
Less08 managing data and concurrencyLess08 managing data and concurrency
Less08 managing data and concurrency
Imran Ali
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
Sidney Chen
 

What's hot (18)

Flashback - The Time Machine..
Flashback - The Time Machine..Flashback - The Time Machine..
Flashback - The Time Machine..
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
Oracle flashback
Oracle flashbackOracle flashback
Oracle flashback
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
 
Oracle 12c New Features for Developers
Oracle 12c New Features for DevelopersOracle 12c New Features for Developers
Oracle 12c New Features for Developers
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
 
High Performance Plsql
High Performance PlsqlHigh Performance Plsql
High Performance Plsql
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependencies
 
Oracle Flashback Query 3
Oracle Flashback Query 3Oracle Flashback Query 3
Oracle Flashback Query 3
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUC
 
Oracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performansOracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performans
 
Less17 flashback tb3
Less17 flashback tb3Less17 flashback tb3
Less17 flashback tb3
 
Less08 managing data and concurrency
Less08 managing data and concurrencyLess08 managing data and concurrency
Less08 managing data and concurrency
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 

Viewers also liked

Gestión de infraestructura tomcat/Tom EE con tfactory
Gestión de infraestructura tomcat/Tom EE con tfactoryGestión de infraestructura tomcat/Tom EE con tfactory
Gestión de infraestructura tomcat/Tom EE con tfactory
Guatemala User Group
 
It's raining data! Oracle databases in the cloud
It's raining data! Oracle databases in the cloudIt's raining data! Oracle databases in the cloud
It's raining data! Oracle databases in the cloud
Guatemala User Group
 
Why to Upgrade to Oracle 12c
Why to Upgrade to Oracle 12cWhy to Upgrade to Oracle 12c
Why to Upgrade to Oracle 12c
Guatemala User Group
 
How Oracle Single/Multitenant will change a DBA's life
How Oracle Single/Multitenant will change a DBA's lifeHow Oracle Single/Multitenant will change a DBA's life
How Oracle Single/Multitenant will change a DBA's life
Guatemala User Group
 
Best Features of Multitenant 12c
Best Features of Multitenant 12cBest Features of Multitenant 12c
Best Features of Multitenant 12c
Guatemala User Group
 
What's next after Upgrade to 12c
What's next after Upgrade to 12cWhat's next after Upgrade to 12c
What's next after Upgrade to 12c
Guatemala User Group
 
Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!
Guatemala User Group
 
SOA y Microservices Diferencias y Aplicaciones
SOA y Microservices Diferencias y AplicacionesSOA y Microservices Diferencias y Aplicaciones
SOA y Microservices Diferencias y Aplicaciones
Guatemala User Group
 
Integracion Continua en Oracle ADF
Integracion Continua en Oracle ADFIntegracion Continua en Oracle ADF
Integracion Continua en Oracle ADF
Guatemala User Group
 
The best Oracle Database 12c Tuning Features for Developers
The best Oracle Database 12c Tuning Features for DevelopersThe best Oracle Database 12c Tuning Features for Developers
The best Oracle Database 12c Tuning Features for Developers
Guatemala User Group
 
Deep Dive: More Oracle Data Pump Performance Tips and Tricks
Deep Dive: More Oracle Data Pump Performance Tips and TricksDeep Dive: More Oracle Data Pump Performance Tips and Tricks
Deep Dive: More Oracle Data Pump Performance Tips and Tricks
Guatemala User Group
 
Introduction to Oracle Clusterware 12c
Introduction to Oracle Clusterware 12cIntroduction to Oracle Clusterware 12c
Introduction to Oracle Clusterware 12c
Guatemala User Group
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of Databases
Guatemala User Group
 
Integration Cloud Service vs SOA
Integration Cloud Service vs SOAIntegration Cloud Service vs SOA
Integration Cloud Service vs SOA
Guatemala User Group
 
Upgrade/Migrate to Oracle 12c: Live and Uncensored!
Upgrade/Migrate to Oracle 12c: Live and Uncensored!Upgrade/Migrate to Oracle 12c: Live and Uncensored!
Upgrade/Migrate to Oracle 12c: Live and Uncensored!
Guatemala User Group
 
ADF 12c como Backend
ADF 12c como BackendADF 12c como Backend
ADF 12c como Backend
Guatemala User Group
 
Cloud Integration for Human Resources: Connect with Your talent in the Cloud
Cloud Integration for Human Resources: Connect with Your talent in the CloudCloud Integration for Human Resources: Connect with Your talent in the Cloud
Cloud Integration for Human Resources: Connect with Your talent in the Cloud
Guatemala User Group
 
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIsLa transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
Guatemala User Group
 
Oracle 12c New Features
Oracle 12c New FeaturesOracle 12c New Features
Oracle 12c New Features
Guatemala User Group
 

Viewers also liked (19)

Gestión de infraestructura tomcat/Tom EE con tfactory
Gestión de infraestructura tomcat/Tom EE con tfactoryGestión de infraestructura tomcat/Tom EE con tfactory
Gestión de infraestructura tomcat/Tom EE con tfactory
 
It's raining data! Oracle databases in the cloud
It's raining data! Oracle databases in the cloudIt's raining data! Oracle databases in the cloud
It's raining data! Oracle databases in the cloud
 
Why to Upgrade to Oracle 12c
Why to Upgrade to Oracle 12cWhy to Upgrade to Oracle 12c
Why to Upgrade to Oracle 12c
 
How Oracle Single/Multitenant will change a DBA's life
How Oracle Single/Multitenant will change a DBA's lifeHow Oracle Single/Multitenant will change a DBA's life
How Oracle Single/Multitenant will change a DBA's life
 
Best Features of Multitenant 12c
Best Features of Multitenant 12cBest Features of Multitenant 12c
Best Features of Multitenant 12c
 
What's next after Upgrade to 12c
What's next after Upgrade to 12cWhat's next after Upgrade to 12c
What's next after Upgrade to 12c
 
Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!
 
SOA y Microservices Diferencias y Aplicaciones
SOA y Microservices Diferencias y AplicacionesSOA y Microservices Diferencias y Aplicaciones
SOA y Microservices Diferencias y Aplicaciones
 
Integracion Continua en Oracle ADF
Integracion Continua en Oracle ADFIntegracion Continua en Oracle ADF
Integracion Continua en Oracle ADF
 
The best Oracle Database 12c Tuning Features for Developers
The best Oracle Database 12c Tuning Features for DevelopersThe best Oracle Database 12c Tuning Features for Developers
The best Oracle Database 12c Tuning Features for Developers
 
Deep Dive: More Oracle Data Pump Performance Tips and Tricks
Deep Dive: More Oracle Data Pump Performance Tips and TricksDeep Dive: More Oracle Data Pump Performance Tips and Tricks
Deep Dive: More Oracle Data Pump Performance Tips and Tricks
 
Introduction to Oracle Clusterware 12c
Introduction to Oracle Clusterware 12cIntroduction to Oracle Clusterware 12c
Introduction to Oracle Clusterware 12c
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of Databases
 
Integration Cloud Service vs SOA
Integration Cloud Service vs SOAIntegration Cloud Service vs SOA
Integration Cloud Service vs SOA
 
Upgrade/Migrate to Oracle 12c: Live and Uncensored!
Upgrade/Migrate to Oracle 12c: Live and Uncensored!Upgrade/Migrate to Oracle 12c: Live and Uncensored!
Upgrade/Migrate to Oracle 12c: Live and Uncensored!
 
ADF 12c como Backend
ADF 12c como BackendADF 12c como Backend
ADF 12c como Backend
 
Cloud Integration for Human Resources: Connect with Your talent in the Cloud
Cloud Integration for Human Resources: Connect with Your talent in the CloudCloud Integration for Human Resources: Connect with Your talent in the Cloud
Cloud Integration for Human Resources: Connect with Your talent in the Cloud
 
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIsLa transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
La transformacion digital en nuestra vida cotidiana. Un vistazo a las APIs
 
Oracle 12c New Features
Oracle 12c New FeaturesOracle 12c New Features
Oracle 12c New Features
 

Similar to Improving the Performance of PL/SQL function calls from SQL

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
Graham Royce
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result Cache
Steven Feuerstein
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013
Andrejs Vorobjovs
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
Eduardo Castro
 
Remote DBA Experts 11g Features
Remote DBA Experts 11g FeaturesRemote DBA Experts 11g Features
Remote DBA Experts 11g Features
Remote DBA Experts
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
sweetysweety8
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
 
Using AWR for SQL Analysis
Using AWR for SQL AnalysisUsing AWR for SQL Analysis
Using AWR for SQL Analysis
Texas Memory Systems, and IBM Company
 
Dba 3+ exp qus
Dba 3+ exp qusDba 3+ exp qus
Dba 3+ exp qus
krreddy21
 
Harnessing the power of both worlds
Harnessing the power of both worldsHarnessing the power of both worlds
Harnessing the power of both worlds
Karan Gulati
 
PL/SQL Tips and Techniques Webinar Presentation
PL/SQL Tips and Techniques Webinar PresentationPL/SQL Tips and Techniques Webinar Presentation
PL/SQL Tips and Techniques Webinar Presentation
Embarcadero Technologies
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
Rodrigo Bastos
 
DBA 3 year Interview Questions
DBA 3 year Interview QuestionsDBA 3 year Interview Questions
DBA 3 year Interview Questions
Naveen P
 
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingTurbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Steven Feuerstein
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 novelties
MSDEVMTL
 
0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial
KlausePaulino
 
New(er) Stuff in PL/SQL
New(er) Stuff in PL/SQLNew(er) Stuff in PL/SQL
New(er) Stuff in PL/SQL
Steven Feuerstein
 

Similar to Improving the Performance of PL/SQL function calls from SQL (20)

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result Cache
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
Remote DBA Experts 11g Features
Remote DBA Experts 11g FeaturesRemote DBA Experts 11g Features
Remote DBA Experts 11g Features
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Using AWR for SQL Analysis
Using AWR for SQL AnalysisUsing AWR for SQL Analysis
Using AWR for SQL Analysis
 
Dba 3+ exp qus
Dba 3+ exp qusDba 3+ exp qus
Dba 3+ exp qus
 
Harnessing the power of both worlds
Harnessing the power of both worldsHarnessing the power of both worlds
Harnessing the power of both worlds
 
PL/SQL Tips and Techniques Webinar Presentation
PL/SQL Tips and Techniques Webinar PresentationPL/SQL Tips and Techniques Webinar Presentation
PL/SQL Tips and Techniques Webinar Presentation
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
 
DBA 3 year Interview Questions
DBA 3 year Interview QuestionsDBA 3 year Interview Questions
DBA 3 year Interview Questions
 
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingTurbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk Processing
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 novelties
 
0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial0396 oracle-goldengate-12c-tutorial
0396 oracle-goldengate-12c-tutorial
 
New(er) Stuff in PL/SQL
New(er) Stuff in PL/SQLNew(er) Stuff in PL/SQL
New(er) Stuff in PL/SQL
 

More from Guatemala User Group

More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12c
Guatemala User Group
 
Oracle Optimizer: 12c New Capabilities
Oracle Optimizer: 12c New CapabilitiesOracle Optimizer: 12c New Capabilities
Oracle Optimizer: 12c New Capabilities
Guatemala User Group
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Guatemala User Group
 
Monitoreo del performance de linux con sar
Monitoreo del performance de linux con sarMonitoreo del performance de linux con sar
Monitoreo del performance de linux con sar
Guatemala User Group
 
Diagnóstico de problemas de red para DBAs
Diagnóstico de problemas de red para DBAsDiagnóstico de problemas de red para DBAs
Diagnóstico de problemas de red para DBAs
Guatemala User Group
 
Cutting edge Essbase
Cutting edge EssbaseCutting edge Essbase
Cutting edge Essbase
Guatemala User Group
 
Gestión de grandes volúmenes de información
Gestión de grandes volúmenes de informaciónGestión de grandes volúmenes de información
Gestión de grandes volúmenes de información
Guatemala User Group
 
RMAN – The Pocket Knife of a DBA
RMAN – The Pocket Knife of a DBA RMAN – The Pocket Knife of a DBA
RMAN – The Pocket Knife of a DBA
Guatemala User Group
 
Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination
Guatemala User Group
 
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and OverviewRe-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
Guatemala User Group
 
Building Better Mobile Backends with Oracle Mobile Cloud Service
Building Better Mobile Backends with Oracle Mobile Cloud Service	Building Better Mobile Backends with Oracle Mobile Cloud Service
Building Better Mobile Backends with Oracle Mobile Cloud Service
Guatemala User Group
 

More from Guatemala User Group (11)

More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12c
 
Oracle Optimizer: 12c New Capabilities
Oracle Optimizer: 12c New CapabilitiesOracle Optimizer: 12c New Capabilities
Oracle Optimizer: 12c New Capabilities
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
 
Monitoreo del performance de linux con sar
Monitoreo del performance de linux con sarMonitoreo del performance de linux con sar
Monitoreo del performance de linux con sar
 
Diagnóstico de problemas de red para DBAs
Diagnóstico de problemas de red para DBAsDiagnóstico de problemas de red para DBAs
Diagnóstico de problemas de red para DBAs
 
Cutting edge Essbase
Cutting edge EssbaseCutting edge Essbase
Cutting edge Essbase
 
Gestión de grandes volúmenes de información
Gestión de grandes volúmenes de informaciónGestión de grandes volúmenes de información
Gestión de grandes volúmenes de información
 
RMAN – The Pocket Knife of a DBA
RMAN – The Pocket Knife of a DBA RMAN – The Pocket Knife of a DBA
RMAN – The Pocket Knife of a DBA
 
Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination Oracle Linux and Oracle Database - A Trusted Combination
Oracle Linux and Oracle Database - A Trusted Combination
 
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and OverviewRe-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
Re-­Think Mobile… Beyond Mobile­‐First: Oracle Mobile Strategy and Overview
 
Building Better Mobile Backends with Oracle Mobile Cloud Service
Building Better Mobile Backends with Oracle Mobile Cloud Service	Building Better Mobile Backends with Oracle Mobile Cloud Service
Building Better Mobile Backends with Oracle Mobile Cloud Service
 

Recently uploaded

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 

Recently uploaded (20)

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 

Improving the Performance of PL/SQL function calls from SQL

  • 1. http://www.oracle-base.com Improving the Performance of PL/SQL Function Calls from SQL Tim Hall Oracle ACE Director Oracle ACE of the Year 2006 OakTable Network OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCP Advanced PL/SQL Developer Oracle Database: SQL Certified Expert http://www.oracle-base.com Books Oracle PL/SQL Tuning Oracle Job Scheduling
  • 2. http://www.oracle-base.com What’s the problem?  We sometimes need to call PL/SQL functions in the select list of queries.  By default, the function may be called for each row returned.  If the function is called repeatedly with the same input parameters, this can represent a massive waste of resources.  Sometimes we are able to change the query, but not the function. Sometimes we can change the function, but not the query. (setup.sql)
  • 3. http://www.oracle-base.com Scalar Subquery Caching  Rewriting function calls as scalar subqueries allows Oracle to cache the results. SELECT (SELECT slow_function(id) FROM dual) FROM func_test;  Oracle sets up an in-memory hash table to cache results of scalar subqueries.  The cache only last for the lifetime of the query.  The cached values are not reusable in the current session or in other sessions.  (scalar.sql)
  • 4. http://www.oracle-base.com DETERMINISTIC Hint  The DETERMINISTIC hint has been available for a long time, but didn’t seem to do much until 10g.  Oracle will optimize calls to functions marked as DETERMINISTIC to improve query performance.  The caching is based on the array size of fetch, so mileage can vary.  Cached return values only last for the lifetime of the call.  The cached values are not reusable in the current session or in other sessions.  (deterministic.sql)
  • 5. http://www.oracle-base.com 11g Result Cache  11g introduced two new caching features.  Both share the same pool of memory in the SGA, controlled using:  RESULT_CACHE_% parameters.  DBMS_RESULT_CACHE package.  V$RESULT_CACHE_% views. (result_cache.sql)  The Query Result Cache improves performance of complex queries that return small number of rows. (query_result_cache.sql)  The Cross-Session PL/SQL Function Result Cache improves performance of function calls by caching the return values. (plsql_result_cache.sql)  Cached results can be reused in the same session and in other sessions.
  • 6. http://www.oracle-base.com Manual Caching Using PL/SQL Collections  Caching of function calls is nothing new.  Caching using PL/SQL collections has been done for many years.  Collections are session-specific, but cached values can be reused in multiple queries.  (collection.sql)  Manually caching can cause problems for volatile data.  Remember, collections use memory. Don’t go nuts!
  • 7. http://www.oracle-base.com Manual Caching Using Contexts  Manual caching using contexts is similar to using collections.  It shares many of the same drawbacks, but can allow a shared cache between sessions.  (context.sql)
  • 8. http://www.oracle-base.com Scalar Subquery Caching (Revisited)  Q: Do other caching methods make scalar subquery caching irrelevant?  A: No. Alternative caching mechanisms don’t reduce context switching between SQL and PL/SQL.  (plsql_result_cache_2.sql)  You should always use scalar subquery caching, even when using other caching mechanisms.  Scalar Subquery Caching reduces context switches, but other methods have added benefits reuse between queries and sessions.
  • 9. http://www.oracle-base.com Is there anything relevant in 12c?  Functions (and procedures) in the WITH clause. Reduces the context switching associated with PL/SQL calls, which improves performance. WITH FUNCTION slow_function(p_id IN NUMBER) IS BEGIN RETURN p_id; END slow_function; SELECT slow_function(id) FROM test_func;
  • 10. http://www.oracle-base.com What about the FROM and WHERE clause?  Function calls in the select list of an inline view follow the same rules as for the main select list.  If you are using table functions, consider switching to pipelined table functions.  Use Scalar Subquery Caching for functions in the WHERE clause if possible.  Avoid functions on indexed columns, or consider function-based indexes. (fbi.sql)
  • 11. http://www.oracle-base.com What did we cover?  Scalar Subquery Caching  DETERMINISTIC Hint  Cross-Session PL/SQL Function Result Cache  Manual Caching Using PL/SQL Collections  Manual Caching Using Contexts  Function calls in the FROM and WHERE clause
  • 12. http://www.oracle-base.com The End…  Slides and Demos: http://www.oracle-base.com/workshops  Questions?