SlideShare a Scribd company logo
1 of 21
Download to read offline
liron@gotodba.com
@amitzil
https://gotodba.com
Liron Amitzi
 Liron Amitzi
 Oracle DBA since 1998 (and Oracle 7)
 Database consultant since 2002
 Oracle ACE
 An independent senior DB consultant
 Recently moved to Vancouver, BC
 BCOUG president
3 Membership Tiers
• Oracle ACE Director
• Oracle ACE
• Oracle ACE Associate
bit.ly/OracleACEProgram
500+ Technical
Experts Helping
Peers Globally
Connect:
Nominate yourself or someone you know: acenomination.oracle.com
@oracleace
Facebook.com/oracleaces
oracle-ace_ww@oracle.com
 Optimizer overview
 Static optimization
 Dynamic optimization
 Static and dynamic optimization features
 Improving our tuning skills
😭😊
 What might cause such a strange behavior?
 How can we debug issues like that?
 Can it be server overload issues?
 Can it be optimizer problem?
 What else can affect the performance in such a way?
6
 One of the most complex pieces in Oracle
 It has one job, to get the best plan possible for a query as
quickly as possible
 The optimizer uses static information (like statistics) to
make decisions
 Lately, Oracle made the optimizer much more
sophisticated, so it can be aware of data collected during
an execution or after it
 And this makes our lives much harder…
 Static information has existed since CBO was introduced
 This is the optimizer's way to get information about the
relevant objects, so it can make smart decisions
 Object statistics, histograms, system statistics, table
structure and more are included here
 There are a lot of math calculations
 Oracle is still improving the information collected
 These are some of the features that allow gathering more
statistics and in more efficient ways:
• Extended statistics (11.1) - gathering statistics for a group of
columns or for expressions
• Synopsis (11.1) - allow collecting NDV more accurately
• New histogram types (12.1) - top frequency and hybrid histograms
• GTT local stats (18c) - allows session statistics for global temp
tables
• Real-Time stats (19c) - additional statistics info for ongoing DMLs
 The static optimization information is limited and the
optimizer sometimes simply can't know stuff
 With this new world of features, the optimizer can be much
more accurate than ever before
 These features kick in when the optimizer realizes
something just before, during or after an execution
 Then it can react to this realization on the spot, or save
information for future use
 The optimizer uses these features to get relevant
information before it executes the optimization process:
• Adaptive cursor sharing (11.2) - allow choosing the best plan with
different values for bind variables
• Automatic degree of parallelism (11.2) - determines the degree
automatically with regards to resources, and allowing statement
queuing
• Dynamic statistics (12.1) - (FKA dynamic sampling), now also
allows persistency of the dynamic information gathered
 The optimizer uses these features when it realizes that
something was wrong with its calculations:
• Cardinality feedback (11.2) - when expected and actual cardinality
differ, feedback is used to allow better plan generation in the future
• Adaptive plans (12.1) - during an execution, if actual cardinality is
way off, the optimizer can change the plan on the fly
 With dynamic optimization, the optimizer is much less
deterministic
 We can't simply copy statistics and some of the data to
reproduce the problem in dev
 We can't even generate a plan and expect it to be the one
that is used
 The DBA job is much more complex now
 We don't only need to understand what the optimizer
does, but what can affect the plan (and now, there is a lot
that can)
 The most important thing is to know as much as we can
about the optimizer features and behavior
 Don't trust an offline execution plan alone
The optimizer tells us a lot about what it does, refer to the
"Note" part after the execution plan in the output:
Note
-----
- cardinality feedback used for this statement
- this is an adaptive plan
- dynamic statistics used: dynamic sampling (level=5)
 Useful tools:
• GATHER_PLAN_STATISTICS hint to capture information of
estimated vs. actual cardinality
• DBMS_XPLAN.display_cursor(format=>'allstats last') to query
estimated vs. actual cardinality
• DBMS_XPLAN.display_cursor(format => 'adaptive') to see
adaptive plans information
 Data Dictionary Views:
• Adaptive Cursor Sharing - the is_bind_sensitive and is_bind_aware
columns in V$SQL indicate if the feature is used for the query
• Dynamic Statistics - the other_xml column in V$SQL_PLAN
contains information about dynamic statistics usage
• Cardinality Feedback - the use_feedback_stats column in
V$SQL_SHARED_CURSOR will show if feedback was used for the
query
• Statement Queuing - the status column in V$SQL_MONITOR will
show the status if the execution (QUEUED)
 SPM allows a conservative SQL execution plan
management
 If SQL plan baselines are present for a query, the
optimizer will have to use one of them
 If it seems that there is a better plan, the optimizer will
have to validate it before it can use it
 By default CAPTURE SQL PLAN is off, but USE SQL
PLANS is on
 It took me a lot of head scratching but not too much time
to find the reason
 The problem in this case was Cardinality Feedback
 This feature in conjunction with an optimizer bug, caused
the optimizer to flip between 2 plans, one good and one
bad, in both the cardinality was wrong
 The solution in this case was to fix the statistics so there
won't be cardinality issues
 As the optimizer is getting more dynamic, the DBA job is
changing from tuning a query to understanding what the
hell is going on
 Today, more than ever, we need to identify the actual plan
that was used
 We need to be very aware of features changing the
optimizer behavior during and after the execution
Liron Amitzi
liron@gotodba.com
@amitzil
https://gotodba.com

More Related Content

What's hot

PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance Tuning
PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance TuningPG2 Cognos TM1: An Introduction to Design, Maintenance and Performance Tuning
PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance TuningPerformanceG2, Inc.
 
DataCluster
DataClusterDataCluster
DataClustergystell
 
Evolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsEvolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsRakuten Group, Inc.
 
Low memory footprint programs-iSeries
Low memory footprint programs-iSeriesLow memory footprint programs-iSeries
Low memory footprint programs-iSeriesPrithiviraj Damodaran
 
Entry Level Reference SQL HyperConverged Architecture
Entry Level Reference SQL HyperConverged ArchitectureEntry Level Reference SQL HyperConverged Architecture
Entry Level Reference SQL HyperConverged ArchitectureJerry Jermann
 
GSM UMTS LTE Site Commissioning software
GSM UMTS LTE Site Commissioning softwareGSM UMTS LTE Site Commissioning software
GSM UMTS LTE Site Commissioning softwareAhmet Ozturk
 
QEI Master Station - SCADA
QEI Master Station - SCADAQEI Master Station - SCADA
QEI Master Station - SCADALeePearce18
 
QEI SCADA Training
QEI SCADA TrainingQEI SCADA Training
QEI SCADA TrainingLeePearce18
 
Exploiting latency bounds for energy efficient load balancing
Exploiting latency bounds for energy efficient load balancingExploiting latency bounds for energy efficient load balancing
Exploiting latency bounds for energy efficient load balancingMichael May
 
Accela NSN Site NodeB Rehome
Accela NSN Site NodeB RehomeAccela NSN Site NodeB Rehome
Accela NSN Site NodeB RehomeAhmet Ozturk
 
Interconnect session 3498: Deployment Topologies for Jazz Reporting Service
Interconnect session 3498: Deployment Topologies for Jazz Reporting ServiceInterconnect session 3498: Deployment Topologies for Jazz Reporting Service
Interconnect session 3498: Deployment Topologies for Jazz Reporting ServiceRosa Naranjo
 
Focus - GSM UMTS LTE Performance and Configuration Management Solution
Focus - GSM UMTS LTE Performance and Configuration Management SolutionFocus - GSM UMTS LTE Performance and Configuration Management Solution
Focus - GSM UMTS LTE Performance and Configuration Management SolutionAhmet Ozturk
 
Stream data from Apache Kafka for processing with Apache Apex
Stream data from Apache Kafka for processing with Apache ApexStream data from Apache Kafka for processing with Apache Apex
Stream data from Apache Kafka for processing with Apache ApexApache Apex
 
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...Continuent
 

What's hot (19)

Madsqlserver
MadsqlserverMadsqlserver
Madsqlserver
 
PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance Tuning
PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance TuningPG2 Cognos TM1: An Introduction to Design, Maintenance and Performance Tuning
PG2 Cognos TM1: An Introduction to Design, Maintenance and Performance Tuning
 
Spirent CloudScore
Spirent CloudScoreSpirent CloudScore
Spirent CloudScore
 
OOW13 Exadata and ODI with Parallel
OOW13 Exadata and ODI with ParallelOOW13 Exadata and ODI with Parallel
OOW13 Exadata and ODI with Parallel
 
DataCluster
DataClusterDataCluster
DataCluster
 
Evolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deploymentsEvolution of unix environments and the road to faster deployments
Evolution of unix environments and the road to faster deployments
 
Pb1252 readme
Pb1252 readmePb1252 readme
Pb1252 readme
 
Low memory footprint programs-iSeries
Low memory footprint programs-iSeriesLow memory footprint programs-iSeries
Low memory footprint programs-iSeries
 
Entry Level Reference SQL HyperConverged Architecture
Entry Level Reference SQL HyperConverged ArchitectureEntry Level Reference SQL HyperConverged Architecture
Entry Level Reference SQL HyperConverged Architecture
 
GSM UMTS LTE Site Commissioning software
GSM UMTS LTE Site Commissioning softwareGSM UMTS LTE Site Commissioning software
GSM UMTS LTE Site Commissioning software
 
QEI Master Station - SCADA
QEI Master Station - SCADAQEI Master Station - SCADA
QEI Master Station - SCADA
 
QEI SCADA Training
QEI SCADA TrainingQEI SCADA Training
QEI SCADA Training
 
Exploiting latency bounds for energy efficient load balancing
Exploiting latency bounds for energy efficient load balancingExploiting latency bounds for energy efficient load balancing
Exploiting latency bounds for energy efficient load balancing
 
Accela NSN Site NodeB Rehome
Accela NSN Site NodeB RehomeAccela NSN Site NodeB Rehome
Accela NSN Site NodeB Rehome
 
Interconnect session 3498: Deployment Topologies for Jazz Reporting Service
Interconnect session 3498: Deployment Topologies for Jazz Reporting ServiceInterconnect session 3498: Deployment Topologies for Jazz Reporting Service
Interconnect session 3498: Deployment Topologies for Jazz Reporting Service
 
Focus - GSM UMTS LTE Performance and Configuration Management Solution
Focus - GSM UMTS LTE Performance and Configuration Management SolutionFocus - GSM UMTS LTE Performance and Configuration Management Solution
Focus - GSM UMTS LTE Performance and Configuration Management Solution
 
Stream data from Apache Kafka for processing with Apache Apex
Stream data from Apache Kafka for processing with Apache ApexStream data from Apache Kafka for processing with Apache Apex
Stream data from Apache Kafka for processing with Apache Apex
 
Mobile cloud sync
Mobile   cloud syncMobile   cloud sync
Mobile cloud sync
 
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...
Webinar Slides: Real-Time Replication vs. ETL - How Analytics Requires New Te...
 

Similar to Dealing With The Optimizer complexity

Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBAKaran Kukreja
 
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)SolarWinds
 
Setting up the Oracle Optimizer for Proof of Concept Testing
Setting up the Oracle Optimizer for Proof of Concept TestingSetting up the Oracle Optimizer for Proof of Concept Testing
Setting up the Oracle Optimizer for Proof of Concept TestingNigel Bayliss
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Nelson Calero
 
Winning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsWinning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsPini Dibask
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
שבוע אורקל 2016
שבוע אורקל 2016שבוע אורקל 2016
שבוע אורקל 2016Aaron Shilo
 
Microsoft SQL Server - SQL Server Migrations Presentation
Microsoft SQL Server - SQL Server Migrations PresentationMicrosoft SQL Server - SQL Server Migrations Presentation
Microsoft SQL Server - SQL Server Migrations PresentationMicrosoft Private Cloud
 
T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersShehap Elnagar
 
Optimizing Callidus TrueComp Suite: Tips and Tricks
Optimizing Callidus TrueComp Suite: Tips and TricksOptimizing Callidus TrueComp Suite: Tips and Tricks
Optimizing Callidus TrueComp Suite: Tips and TricksCallidus Software
 
LVOUG meetup #2 - Forcing SQL Execution Plan Instability
LVOUG meetup #2 - Forcing SQL Execution Plan InstabilityLVOUG meetup #2 - Forcing SQL Execution Plan Instability
LVOUG meetup #2 - Forcing SQL Execution Plan InstabilityMaris Elsins
 
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...Daniel Martin
 
High Performance SSRS
High Performance SSRSHigh Performance SSRS
High Performance SSRSBert Wagner
 
SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningSQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningJavier Villegas
 
Winning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsWinning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsPini Dibask
 

Similar to Dealing With The Optimizer complexity (20)

Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
 
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
 
Setting up the Oracle Optimizer for Proof of Concept Testing
Setting up the Oracle Optimizer for Proof of Concept TestingSetting up the Oracle Optimizer for Proof of Concept Testing
Setting up the Oracle Optimizer for Proof of Concept Testing
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
 
Winning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsWinning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editions
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
dd presentation.pdf
dd presentation.pdfdd presentation.pdf
dd presentation.pdf
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
שבוע אורקל 2016
שבוע אורקל 2016שבוע אורקל 2016
שבוע אורקל 2016
 
Microsoft SQL Server - SQL Server Migrations Presentation
Microsoft SQL Server - SQL Server Migrations PresentationMicrosoft SQL Server - SQL Server Migrations Presentation
Microsoft SQL Server - SQL Server Migrations Presentation
 
T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powers
 
Optimizing Callidus TrueComp Suite: Tips and Tricks
Optimizing Callidus TrueComp Suite: Tips and TricksOptimizing Callidus TrueComp Suite: Tips and Tricks
Optimizing Callidus TrueComp Suite: Tips and Tricks
 
LVOUG meetup #2 - Forcing SQL Execution Plan Instability
LVOUG meetup #2 - Forcing SQL Execution Plan InstabilityLVOUG meetup #2 - Forcing SQL Execution Plan Instability
LVOUG meetup #2 - Forcing SQL Execution Plan Instability
 
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...
IBM Insight 2013 - Aetna's production experience using IBM DB2 Analytics Acce...
 
High Performance SSRS
High Performance SSRSHigh Performance SSRS
High Performance SSRS
 
SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningSQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
 
Winning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editionsWinning performance challenges in oracle standard editions
Winning performance challenges in oracle standard editions
 

Recently uploaded

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Dealing With The Optimizer complexity

  • 2.  Liron Amitzi  Oracle DBA since 1998 (and Oracle 7)  Database consultant since 2002  Oracle ACE  An independent senior DB consultant  Recently moved to Vancouver, BC  BCOUG president
  • 3. 3 Membership Tiers • Oracle ACE Director • Oracle ACE • Oracle ACE Associate bit.ly/OracleACEProgram 500+ Technical Experts Helping Peers Globally Connect: Nominate yourself or someone you know: acenomination.oracle.com @oracleace Facebook.com/oracleaces oracle-ace_ww@oracle.com
  • 4.  Optimizer overview  Static optimization  Dynamic optimization  Static and dynamic optimization features  Improving our tuning skills
  • 6.  What might cause such a strange behavior?  How can we debug issues like that?  Can it be server overload issues?  Can it be optimizer problem?  What else can affect the performance in such a way? 6
  • 7.  One of the most complex pieces in Oracle  It has one job, to get the best plan possible for a query as quickly as possible  The optimizer uses static information (like statistics) to make decisions  Lately, Oracle made the optimizer much more sophisticated, so it can be aware of data collected during an execution or after it  And this makes our lives much harder…
  • 8.  Static information has existed since CBO was introduced  This is the optimizer's way to get information about the relevant objects, so it can make smart decisions  Object statistics, histograms, system statistics, table structure and more are included here  There are a lot of math calculations  Oracle is still improving the information collected
  • 9.  These are some of the features that allow gathering more statistics and in more efficient ways: • Extended statistics (11.1) - gathering statistics for a group of columns or for expressions • Synopsis (11.1) - allow collecting NDV more accurately • New histogram types (12.1) - top frequency and hybrid histograms • GTT local stats (18c) - allows session statistics for global temp tables • Real-Time stats (19c) - additional statistics info for ongoing DMLs
  • 10.  The static optimization information is limited and the optimizer sometimes simply can't know stuff  With this new world of features, the optimizer can be much more accurate than ever before  These features kick in when the optimizer realizes something just before, during or after an execution  Then it can react to this realization on the spot, or save information for future use
  • 11.  The optimizer uses these features to get relevant information before it executes the optimization process: • Adaptive cursor sharing (11.2) - allow choosing the best plan with different values for bind variables • Automatic degree of parallelism (11.2) - determines the degree automatically with regards to resources, and allowing statement queuing • Dynamic statistics (12.1) - (FKA dynamic sampling), now also allows persistency of the dynamic information gathered
  • 12.  The optimizer uses these features when it realizes that something was wrong with its calculations: • Cardinality feedback (11.2) - when expected and actual cardinality differ, feedback is used to allow better plan generation in the future • Adaptive plans (12.1) - during an execution, if actual cardinality is way off, the optimizer can change the plan on the fly
  • 13.  With dynamic optimization, the optimizer is much less deterministic  We can't simply copy statistics and some of the data to reproduce the problem in dev  We can't even generate a plan and expect it to be the one that is used
  • 14.  The DBA job is much more complex now  We don't only need to understand what the optimizer does, but what can affect the plan (and now, there is a lot that can)  The most important thing is to know as much as we can about the optimizer features and behavior  Don't trust an offline execution plan alone
  • 15. The optimizer tells us a lot about what it does, refer to the "Note" part after the execution plan in the output: Note ----- - cardinality feedback used for this statement - this is an adaptive plan - dynamic statistics used: dynamic sampling (level=5)
  • 16.  Useful tools: • GATHER_PLAN_STATISTICS hint to capture information of estimated vs. actual cardinality • DBMS_XPLAN.display_cursor(format=>'allstats last') to query estimated vs. actual cardinality • DBMS_XPLAN.display_cursor(format => 'adaptive') to see adaptive plans information
  • 17.  Data Dictionary Views: • Adaptive Cursor Sharing - the is_bind_sensitive and is_bind_aware columns in V$SQL indicate if the feature is used for the query • Dynamic Statistics - the other_xml column in V$SQL_PLAN contains information about dynamic statistics usage • Cardinality Feedback - the use_feedback_stats column in V$SQL_SHARED_CURSOR will show if feedback was used for the query • Statement Queuing - the status column in V$SQL_MONITOR will show the status if the execution (QUEUED)
  • 18.  SPM allows a conservative SQL execution plan management  If SQL plan baselines are present for a query, the optimizer will have to use one of them  If it seems that there is a better plan, the optimizer will have to validate it before it can use it  By default CAPTURE SQL PLAN is off, but USE SQL PLANS is on
  • 19.  It took me a lot of head scratching but not too much time to find the reason  The problem in this case was Cardinality Feedback  This feature in conjunction with an optimizer bug, caused the optimizer to flip between 2 plans, one good and one bad, in both the cardinality was wrong  The solution in this case was to fix the statistics so there won't be cardinality issues
  • 20.  As the optimizer is getting more dynamic, the DBA job is changing from tuning a query to understanding what the hell is going on  Today, more than ever, we need to identify the actual plan that was used  We need to be very aware of features changing the optimizer behavior during and after the execution