This session was delivered as part of the EMEA Ground Breakers tour in Romania, Oct. 2019. The execution plan for a SQL statement can often seem complicated and hard to understand. Determining if the execution plan you are looking at is the best plan you could get or attempting to improve a poorly performing execution plan can be a daunting task even for the most experienced DBA or developer. This session examines the different aspects of an execution plan, from selectivity to parallel execution and explains what information you should be gleaming from the plan and how it affects the execution. It offers insight into what caused the Optimizer to make the decision it did as well as a set of corrective measures that can be used to improve each aspect of the plan.
Part 3 of the SQL Tuning workshop examines the different aspects of an execution plan, from cardinality estimates to parallel execution and explains what information you should be gleaming from the plan and how it affects the execution. It offers insight into what caused the Optimizer to make the decision it did as well as a set of corrective measures that can be used to improve each aspect of the plan.
Part4 Influencing Execution Plans with Optimizer HintsMaria Colgan
Part 4 of the SQL Tuning workshop is called “Harnessing the power of optimizer hints”. Although I am not a strong supporter of adding hints to SQL statements for a whole host of reasons, from time to time, it may become necessary to influence the plan the Optimizer chooses. The most powerful way to alter the plan chosen is via Optimizer hints. But knowing when and how to use Optimizer hints correctly is somewhat of a dark art. This session explains how Optimizer hints are interpreted, when and where they should be used, and why they sometimes appear to be ignored.
Part2 Best Practices for Managing Optimizer StatisticsMaria Colgan
Part 2 of the SQL Tuning workshop focuses on Optimizer Statistics and the best practices for managing them, including when and how to gather statistics. It also covers what additional information you may need to give the Optimizer and provides guidance on when not to gather statistics. Finally we look at all of the techniques you can use to speed up statistics gathering including taking advantage of Incremental statistics, parallelism and concurrency.
The final part of the SQL Tuning workshop focuses on applying the techniques discussed in the previous sections to help diagnose and correct a number of problematic SQL statements and shows how you can use SQL Plan Management or a SQL Patch to influence an execution plan.
Part1 of SQL Tuning Workshop - Understanding the OptimizerMaria Colgan
Part 1 of a 5 part SQL Tuning workshop, This presentation covers the history of the Oracle Optimizer and explains the first thing the Optimizer does when it receives a SQL statements, which is to transform the SQL statement in order to open up additional access paths.
Five Tips to Get the Most Out of Your IndexingMaria Colgan
This is one of the 15 minute "TED" style talk presented as part of the Database Symposium at the ODTUG Kscope18 conference. In this presentation @SQLMaria provides 5 useful tips for getting the most out of indexes in the Oracle Database
This is one of the 15 minute "TED" style talk presented as part of the Database Symposium at the ODTUG Kscope18 conference. In this presentation @SQLMaria shares details on 4 useful supplied PL/SQL package with the Oracle Database
Part 3 of the SQL Tuning workshop examines the different aspects of an execution plan, from cardinality estimates to parallel execution and explains what information you should be gleaming from the plan and how it affects the execution. It offers insight into what caused the Optimizer to make the decision it did as well as a set of corrective measures that can be used to improve each aspect of the plan.
Part4 Influencing Execution Plans with Optimizer HintsMaria Colgan
Part 4 of the SQL Tuning workshop is called “Harnessing the power of optimizer hints”. Although I am not a strong supporter of adding hints to SQL statements for a whole host of reasons, from time to time, it may become necessary to influence the plan the Optimizer chooses. The most powerful way to alter the plan chosen is via Optimizer hints. But knowing when and how to use Optimizer hints correctly is somewhat of a dark art. This session explains how Optimizer hints are interpreted, when and where they should be used, and why they sometimes appear to be ignored.
Part2 Best Practices for Managing Optimizer StatisticsMaria Colgan
Part 2 of the SQL Tuning workshop focuses on Optimizer Statistics and the best practices for managing them, including when and how to gather statistics. It also covers what additional information you may need to give the Optimizer and provides guidance on when not to gather statistics. Finally we look at all of the techniques you can use to speed up statistics gathering including taking advantage of Incremental statistics, parallelism and concurrency.
The final part of the SQL Tuning workshop focuses on applying the techniques discussed in the previous sections to help diagnose and correct a number of problematic SQL statements and shows how you can use SQL Plan Management or a SQL Patch to influence an execution plan.
Part1 of SQL Tuning Workshop - Understanding the OptimizerMaria Colgan
Part 1 of a 5 part SQL Tuning workshop, This presentation covers the history of the Oracle Optimizer and explains the first thing the Optimizer does when it receives a SQL statements, which is to transform the SQL statement in order to open up additional access paths.
Five Tips to Get the Most Out of Your IndexingMaria Colgan
This is one of the 15 minute "TED" style talk presented as part of the Database Symposium at the ODTUG Kscope18 conference. In this presentation @SQLMaria provides 5 useful tips for getting the most out of indexes in the Oracle Database
This is one of the 15 minute "TED" style talk presented as part of the Database Symposium at the ODTUG Kscope18 conference. In this presentation @SQLMaria shares details on 4 useful supplied PL/SQL package with the Oracle Database
This paper describes how the optimizer uses statistics and determines plans for executing SQL statement. It explains how the 10053 trace file can be used to understand Oracle's decisions on execution plans.
This presentation features the fundamentals of SQL tunning like SQL Processing, Optimizer and Execution Plan, Accessing Tables, Performance Improvement Consideration Partition Technique. Presented by Alphalogic Inc : https://www.alphalogicinc.com/
This presentation deals with the advanced features of SQL comprising of Arithmetic Calculations, Analytical Function, PIVOT etc. Presented by Alphalogic Inc: https://www.alphalogicinc.com/
This is a paper I wrote at Hotsos where we used Method-R and Trace Data to optimize performance. SQL tuning can be simple if you ask the right questions.
This is a presentation that identifies the various components of the 11i technology stack and how to generate log files for them for troubleshooting and debugging.
This is a presentation that describes how Oracle uses histograms to make decisions on SQL query execution. To see the actual webinar and demo, go https://portal.hotsos.com/events/webinars/
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
Tutorial at Oracle Open World 2015:
Performance of SQL queries plays a big role in application performance. If some queries execute slowly, these queries or the database schema may need tuning. This tutorial covers query processing, optimization methods, and how the MySQL optimizer chooses a specific plan to execute SQL. See demonstrations on how to use tools such as EXPLAIN (including the JSON-based variant), optimizer trace, and performance schema to analyze query plans. See how the Visual Explain functionality in MySQL Workbench helps you to visualize these plans. Based on the analysis, the tutorial covers how to take the next steps for performance tuning. It might mean forcing a particular index, changing the schema, or modifying configuration parameters.
Optimal query access plans are essential for good data server performance and it is the DB2 for Linux, UNIX and Windows query optimizer's job to choose the best access plan. However, occasionally queries that were performing well suddenly degrade, due to an unexpected access plan change. This presentation will cover a number of best practices to ensure that access plans don't unexpectedly change for the worse. All access plans can be made more stable with accurate DB statistics and proper DB configuration. DB2 9.7 provides a new feature to stabilize access plans for static SQL across binds and rebinds, which is particularly important for applications using SQL Procedural Language. When all else fails, optimization profiles can be used to force the desired access plan. This presentation will show you how to develop and implement a strategy to ensure your access plans are rock-solid.
[pdf presentation with notes]
Online Statistics Gathering for Bulk Loads - the official name of the feature - was introduced in Oracle 12.1. The idea is to gather optimizer statistics "on the fly" for direct path loads. Sounds good for ETL? In certain scenarios it makes sense but even then there are many points to consider so that it becomes a reliable part of your ETL processes. When exactly will it be working and when not? Do you prevent it yourself? Documented, undocumented cases, known bugs. Which statistics are gathered and which are not? What has to be considered with partitioned tables? Interval partitioning - special case?
This paper describes how the optimizer uses statistics and determines plans for executing SQL statement. It explains how the 10053 trace file can be used to understand Oracle's decisions on execution plans.
This presentation features the fundamentals of SQL tunning like SQL Processing, Optimizer and Execution Plan, Accessing Tables, Performance Improvement Consideration Partition Technique. Presented by Alphalogic Inc : https://www.alphalogicinc.com/
This presentation deals with the advanced features of SQL comprising of Arithmetic Calculations, Analytical Function, PIVOT etc. Presented by Alphalogic Inc: https://www.alphalogicinc.com/
This is a paper I wrote at Hotsos where we used Method-R and Trace Data to optimize performance. SQL tuning can be simple if you ask the right questions.
This is a presentation that identifies the various components of the 11i technology stack and how to generate log files for them for troubleshooting and debugging.
This is a presentation that describes how Oracle uses histograms to make decisions on SQL query execution. To see the actual webinar and demo, go https://portal.hotsos.com/events/webinars/
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
Tutorial at Oracle Open World 2015:
Performance of SQL queries plays a big role in application performance. If some queries execute slowly, these queries or the database schema may need tuning. This tutorial covers query processing, optimization methods, and how the MySQL optimizer chooses a specific plan to execute SQL. See demonstrations on how to use tools such as EXPLAIN (including the JSON-based variant), optimizer trace, and performance schema to analyze query plans. See how the Visual Explain functionality in MySQL Workbench helps you to visualize these plans. Based on the analysis, the tutorial covers how to take the next steps for performance tuning. It might mean forcing a particular index, changing the schema, or modifying configuration parameters.
Optimal query access plans are essential for good data server performance and it is the DB2 for Linux, UNIX and Windows query optimizer's job to choose the best access plan. However, occasionally queries that were performing well suddenly degrade, due to an unexpected access plan change. This presentation will cover a number of best practices to ensure that access plans don't unexpectedly change for the worse. All access plans can be made more stable with accurate DB statistics and proper DB configuration. DB2 9.7 provides a new feature to stabilize access plans for static SQL across binds and rebinds, which is particularly important for applications using SQL Procedural Language. When all else fails, optimization profiles can be used to force the desired access plan. This presentation will show you how to develop and implement a strategy to ensure your access plans are rock-solid.
[pdf presentation with notes]
Online Statistics Gathering for Bulk Loads - the official name of the feature - was introduced in Oracle 12.1. The idea is to gather optimizer statistics "on the fly" for direct path loads. Sounds good for ETL? In certain scenarios it makes sense but even then there are many points to consider so that it becomes a reliable part of your ETL processes. When exactly will it be working and when not? Do you prevent it yourself? Documented, undocumented cases, known bugs. Which statistics are gathered and which are not? What has to be considered with partitioned tables? Interval partitioning - special case?
Design and develop with performance in mind
Establish a tuning environment
Index wisely
Reduce parsing
Take advantage of Cost Based Optimizer
Avoid accidental table scans
Optimize necessary table scans
Optimize joins
Use array processing
Consider PL/SQL for “tricky” SQL
In this first of a series of presentations, we'll overview the differences between SQL and PL/SQL, and the first steps in optimization, as understanding RULE vs. COST, and how to slash 90% response time in data extractions running in SQL*Plus.
This slideshow aims to convey the basics of Oracle Database. This slideshow captures all the essential concepts and necessary visualizations to capture all the key concepts of Oracle RDBMS, along with providing all the essential steps to install it on your system, whether it be on Mac or Windows. Capturing all the concepts precisely and cogently, it also explains key concepts like joins in a diagrammatic fashion enabling viewers to visualize them for easier understanding and retention, along with providing them with the syntax to pick up writing simple queries.
This paper describes the evolution of the Plan table and DBMSX_PLAN in 11g and some of the features that can be used to troubelshoot SQL performance effectively and efficiently.
In this session, we looked at five things you might not know about the Oracle Database or might have forgotten. For each topic, I explained the functionality and demonstrated the benefits using real-world examples. The topics covered apply to anyone running Oracle Database 11g and up, including Standard Edition, with only a few minor exceptions.
This session was delivered as part of the Oracle Ground Breakers EMEA tour in Romania. What does "autonomous" really mean, and what makes the database autonomous? If you're looking for the answers to these questions, this is the session for you! In this session, we invite you to take a peek under the hood of the Oracle Autonomous Database, so you can get a clear understanding of how our unique Autonomous Database works. We’ll share our exclusive combination of database features, best practices and machine learning algorithms that make up this family of cloud services. With the use of live demos, we’ll illustrates how it can simplify your approach to data management and accelerate your transition to the cloud.
What to Expect From Oracle database 19cMaria Colgan
The Oracle Database has recently switched to an annual release model. Oracle Database 19c is only the second release in this new model. So what can you expect from the latest version of the Oracle Database? This presentation explains how Oracle Database 19c is really 12.2.0.3 the terminal release of the 12.2 family and the new features you can find in this release.
The presentation helps to introduce the key aspects of the Oracle Optimizer and how you find out what it's up to and how you can influence its decisions.
The Changing Role of a DBA in an Autonomous WorldMaria Colgan
The advent of the cloud and the introduction of Oracle Autonomous Database Cloud presents opportunities for every organization, but what's the future role for the DBA? This presentation explores how the role of the DBA will continue to evolve, and provides advice on key skills required to be a successful DBA in the world of the cloud.
This presentation provides a clear overview of how Oracle Database In-Memory optimizes both analytics and mixed workloads, delivering outstanding performance while supporting real-time analytics, business intelligence, and reporting. It provides details on what you can expect from Database In-Memory in both Oracle Database 12.1.0.2 and 12.2.
This is one of the 15 minute "TED" style talk presented as part of the Database Symposium at the ODTUG Kscope18 conference. In this presentation @SQLMaria coveres topics like what data type you should use to store JSON documents (varchar2, clob or blob) the pro's and con's of using an IS JSON check constraint, and how to load, index, and query JSON documents.
Harnessing the Power of Optimizer HintsMaria Colgan
The goal of the Oracle Optimizer is to examine all possible execution plans for a SQL statement and to pick the one with the lowest cost, which should be the most efficient. From time to time, it may become necessary to influence the plan the Optimizer chooses. The most powerful way to alter the plan chosen is via Optimizer hints. But knowing when and how to use Optimizer hints correctly is somewhat of a dark art. This session explains in detail how Optimizer hints are interpreted, when they should be used, and why they sometimes appear to be ignored.
Databases are fundamentally changing due to new technologies and new requirements. This has never been more evident than with Oracle Database 12c, which has been the most rapidly adopted release in over a decade. This session provides a technical introduction to what's new in Oracle Database 12c and Oracle’s Engineered systems. We will describe which industry transformation inspired each enhancement and explain when and how you can embrace each enhancement while preserving your existing performance.
For decades developers and DBAs have battled over who controls the world. With each new development paradigm the battle flares again as developers push DBAs to adopt and support new data structures (JSON), new APIs (REST services), new technologies (In-Memory) and new platforms (Cloud). In this session, Gerald Venzl takes on the role of lead developer on a project to deploy a RESTful web-based application for a new coffeeshop chain, while Maria Colgan takes on the role of the DBA. Through the use of live demos, they learn to work together to find a solution that will allow them to embrace a more agile development approach, as well as the latest technology trends without exposing the business to painful availability or security vulnerabilities.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
4. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
4
Understanding execution plans
Execution Plan Example
5. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
5
Understanding execution plans
Execution Plan Example
6. What is an execution plan?
Query:
SELECT prod_category, avg(amount_sold)
FROM sales s, products p
WHERE p.prod_id = s.prod_id
GROUP BY prod_category;
HASH JOIN
TABLE
ACCESS
SALES
Tree-shaped representation of
plan
TABLE
ACCESS
PRODUCTS
GROUP BY
Tabular representation of plan
7. Additional information under the execution plan
Access predicate
• Where clause predicate used
for data retrieval
• The start and stop keys for an index
• If rowids are passed to a table scan
8. Filter predicate
Where clause predicate that
not used for data retrieval but
to eliminate uninteresting row
once the data is found
Additional information under the execution plan
9. Note Section
Details on Optimizer
features used such as:
Rule Based Optimizer (RBO)
Dynamic Sampling
Outlines
SQL Profiles or plan baselines
Adaptive Plans
Hints (Starting in 19c)
Additional information under the execution plan
10. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
10
Understanding execution plans
Execution Plan Example
11. Autotrace SQL Monitor
11
SQL Developer TKPROF
Many ways to view an execution plan
…..But there are actually only 2 ways to generate one
12. How to generate an execution plan
1.EXPLAIN PLAN command
Displays an execution plan for a SQL statement without actually executing the
statement
2.V$SQL_PLAN
A dictionary view introduced in Oracle 9i that shows the execution plan for a SQL
statement that has been compiled into a cursor in the cursor cache
Two methods for looking at the execution plan
Under certain conditions the plan shown with EXPLAIN PLAN
can be different from the plan shown using V$SQL_PLAN
13. How to generate an execution plan
SQL> EXPLAIN PLAN FOR
SELECT p.prod_name, avg(s.amount_sold)
FROM sales s, products p
WHERE p.prod_id = s.prod_id
GROUP BY p.prod_name;
SQL> SELECT * FROM
table(dbms_xplan.display('plan_table',null,'basic'));
EXPLAIN PLAN command & dbms_xplan.display function
PLAN TABLE
NAME
STATEMENT
ID
FORMAT
14. How to generate an execution plan
SQL> SELECT p.prod_name, avg(s.amount_sold)
FROM sales s, products p
WHERE p.prod_id = s.prod_id
GROUP BY p.prod_name;
SQL> SELECT * FROM
table(dbms_xplan.display_cursor(null, null, 'basic'));
Generate & display plan for last SQL statements executed in session
SQL_ID CHILD
NUMBER
FORMAT
• Format* is highly customizable - Basic ,Typical, All
– Additional low level parameters show more detail
*More information on formatting on Optimizer blog
15. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
Understanding execution plans
• Cardinality
• Access paths
• Join methods
• Join order
Execution Plan Example
15
16. Cardinality
What is it?
Estimate of number rows that will be returned by each operation
Why should you care?
It influences everything! Access method, Join type, Join Order etc.
How does the Optimizer Determine it?
Cardinality for a single column equality predicate = total num of rows
num of distinct values
For example: A table has 100 rows, a column has 5 distinct values =>
cardinality=20 rows
More complicated predicates have more complicated cardinality calculation
17. Identifying cardinality in an execution plan
Cardinality - estimated #
of rows returned
Determine correct cardinality using a SELECT
COUNT(*) from each table applying any
WHERE Clause predicates belonging to that
table
18. Checking cardinality estimates
SELECT /*+ gather_plan_statistics */
p.prod_name, SUM(s.quantity_sold)
FROM sales s, products p
WHERE s.prod_id =p.prod_id
GROUP BY p.prod_name ;
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
19. Checking cardinality estimates
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
Compare estimated number of rows (E-Rows) with actual
rows returned (A-Rows)
20. Checking cardinality estimates
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
Extra information you get with ALLSTATS
Starts indicates the number of times that step or operation was done
In this case the SALES table is partitioned and has 28 partitions
21. Checking cardinality estimates
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
Extra information you get with ALLSTATS
Buffers indicates the number of buffers that need to be read for
each step
22. Checking cardinality estimates
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
Extra information you get with ALLSTATS
0Mem - estimated amount of memory needed
1Mem - amount of memory need to perform the operation in 1 pass
Used-Mem - actual amount of memory used and number of passes required
23. Checking cardinality estimates for Parallel Execution
SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
Note: a lot of the data is zero in
the A-rows column because we
only show last executed cursor
which is the QC. Need to use
ALLSTATS ALL to see info on all
parallel server cursors
24. SELECT * FROM table (
DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS ALL'));
Checking cardinality estimates for Parallel Execution
25. Easiest way to compare the estimated number of rows returned
with actual rows returned
Check cardinality using SQL Monitor
26. Solutions to incorrect cardinality estimates
Cause Solution
Stale or missing statistics DBMS_STATS
Data Skew Create a histogram
Multiple single column predicates on a table Create a column group using
DBMS_STATS.CREATE_EXTENDED_STATS
Function wrapped column Create statistics on the funct wrapped
column using
DBMS_STATS.CREATE_EXTENDED_STATS
Multiple columns used in a join Create a column group on join columns
using DBMS_STATS.CREATE_EXTENDED_STAT
Complicated expression containing columns
from multiple tables
Use dynamic sampling level 4 or higher
27. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
Understanding execution plans
• Cardinality
• Access paths
• Join methods
• Join order
Execution Plan Example
27
28. Access paths – Getting the data
Access Path Explanation
Full table scan Reads all rows from table & filters out those that do not meet the where clause predicates. Used when
no index, DOP set etc
Table access by Rowid Rowid specifies the datafile & data block containing the row and the location of the row in that block.
Used if rowid supplied by index or in where clause
Index unique scan Only one row will be returned. Used when table contains a UNIQUE or a PRIMARY KEY constraint that
guarantees that only a single row is accessed
Index range scan Accesses adjacent index entries returns ROWID values Used with equality on non-unique indexes or
range predicate on unique indexes (<.>, between etc)
Index skip scan Skips the leading edge (column) of the index & uses the rest Advantageous if there are few distinct
values in the leading column and many distinct values in the non-leading column or columns of the
index
Full index scan Processes all leaf blocks of an index, but only enough branch blocks to find 1st leaf block. Used when all
necessary columns are in index & order by clause matches index structure or if a sort merge join is done
Fast full index scan Scans all blocks in index used to replace a Full Table Scan when all necessary columns are in the index.
Using multi-block IO & can going parallel
Index joins Hash join of several indexes that together contain all the table columns that are referenced in the query.
Won’t eliminate a sort operation
Bitmap indexes Uses a bitmap for key values and a mapping function that converts each bit position to a rowid. Can
efficiently merge indexes that correspond to several conditions in a WHERE clause
29. Identifying access paths in an execution plan
If the wrong access method is being used check cardinality, join order…
Look in Operation section to see how
an object is being accessed
30. Access path example 1
Table customers contains 10K rows & has a primary key on cust_id
SELECT country_id, name
FROM customers
WHERE cust_id IN (100,200,100000);
What plan would you expect for this query?
Predicate Information (identified by operation id):
----------------------------------------------------------------------
3 - access("CUST_ID"=100 OR "CUST_ID"=200 OR "CUST_ID"=100000)
31. Access path example 2
Table customers contains 10K rows & has a primary key on cust_id
SELECT country_id, name
FROM customers
WHERE cust_id BETWEEN 100 AND 150;
What plan would you expect for this query?
32. Access path example 3
Table customers contains 10K rows & has a primary key on cust_id
SELECT country_id, name
FROM customers
WHERE country_name = ‘USA’;
What plan would you expect for this query?
33. Common access path issues
Issue Cause
Uses a table scan instead of index DOP on table but not index, value of MBRC
Picks wrong index Stale or missing statistics
Cost of full index access is cheaper than index
look up followed by table access
Picks index that matches most # of column
34. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
Understanding execution plans
• Cardinality
• Access paths
• Join methods
• Join order
Execution Plan Example
34
35. Join methods
Join Methods Explanation
Nested Loops joins For every row in the outer table, Oracle accesses all the rows in the inner table
Useful when joining small subsets of data and there is an efficient way to access the
second table (index look up)
Hash Joins The smaller of two tables is scan and resulting rows are used to build a hash table
on the join key in memory. The larger table is then scan, join column of the resulting
rows are hashed and the values used to probing the hash table to find the matching
rows. Useful for larger tables & if equality predicate
Sort Merge joins Consists of two steps:
1. Sort join operation: Both the inputs are sorted on the join key.
2. Merge join operation: The sorted lists are merged together.
Useful when the join condition between two tables is an inequality condition
36. Join types
Join Type Explanation
Inner Joins Returns all rows that satisfy the join condition
Outer Joins Returns all rows that satisfy the join condition and also returns all of the rows from the table
without the (+) for which no rows from the other table satisfy the join condition
Cartesian
Joins
Joins every row from one data source with every row from the other data source, creating
the Cartesian Product of the two sets. Only good if tables are very small. Only choice if
there is no join condition specified in query
Semi-Join Returns a row from the outer table when a matching row exists in the subquery data set.
Typically used when there is an EXISTS or an IN predicate, where we aren’t interested in
returning rows from the subquery but merely checking a match exists
Anti-Join Returns a row from the outer table when a matching row does not exist in the subquery data
set. Typically used when there is a NOT EXISTS or NOT IN predicate, where we aren’t
interested in returning rows from the subquery but merely checking a match doesn’t exists
A B
37. Identifying join methods in an execution plan
If wrong join type is used check stmt is written correctly & cardinality
estimates
Look in the Operation section to
check the right join type is used
38. Join method example 1
SELECT e.last_name, e.salary, d.department_name
FROM hr.employees e, hr.departments d
WHERE d.departments_name IN ('Marketing‘,'Sales')
AND e.department_id = d.department_id;
Employees has 107 rows
Departments has 27 rows
Foreign key relationship between Employees and Departments on dept_id
What join method would you expect for this query?
39. Join method example 1
SELECT e.last_name, e.salary, d.department_name
FROM hr.employees e, hr.departments d
WHERE d.departments_name IN ('Marketing‘,'Sales')
AND e.department_id = d.department_id;
What join method would you expect for this query?
40. Join method example 2
SELECT o.customer_id, l.unit_price * l.quantity
FROM oe.orders o, oe.order_items l
WHERE l.order_id = o.order_id;
Orders has 105 rows
Order Items has 665 rows
What join method would you expect for this query?
41. Join method example 2
SELECT o.customer_id, l.unit_price * l.quantity
FROM oe.orders o ,oe.order_items l
WHERE l.order_id = o.order_id;
Orders has 105 rows
Order Items has 665 rows
What join method would you expect for this query?
42. Join type example 1
SELECT o.order_id, o.order_date ,e.name
FROM oe.orders o , hr.employees e;
Orders has 105 rows
Employees has 107 rows
What join type should be use for this query?
43. Join type example 1
SELECT o.order_id, o.order_date, e.name
FROM oe.orders o , hr.employees e;
What join type should be use for this query?
44. Join type example
SELECT s.quantity_sold
FROM sales s, customers c
WHERE s.cust_id =c.cust_id;
Sales table has 960 Rows
Customer table has 55,500 rows
Customer has a primary key created on cust_id
Sales has a foreign key created on cust_id
What join type should be use for this query?
45. What join type should be use for this query?
Join type example
SELECT s.quantity_sold
FROM sales s, customers c
WHERE s.cust_id =c.cust_id;
No join is needed
Table elimination transformation
Optimizer realizes that the join to
customers tables is redundant as no
columns are selected Presence of
primary –foreign key relationship
means we can remove table
46. What causes wrong join method to be
selected
Issue Cause
Nested loop selected instead of hash join Cardinality estimate on the left side is
under estimated triggers Nested loop to
be selected
Hash join selected instead of nested loop In case of a hash join the Optimizer
doesn’t taken into consideration the
benefit of caching. If rows on the left
come in a clustered or ordered fashion
so the probe into 2nd table is more
efficient
Cartesian Joins Cardinality underestimation
Adaptive Plans in 12c can address
these problems on the fly by
changing the join method after you
see what data is coming out of the
left hand side of the join
47. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
Understanding execution plans
• Cardinality
• Access paths
• Join methods
• Join order
Execution Plan Example
47
48. Join order
• The order in which the tables are join in a multi table statement
• Ideally start with the table that will eliminate the most rows
• Strongly affected by the access paths available
• Some basic rules
• Joins guaranteed to produce at most one row always go first
• Joins between two row sources that have only one row each
• When outer joins are used the table with the outer join operator must
come after the other table in the predicate
• If view merging is not possible all tables in the view will be joined before
joining to the tables outside the view
49. Identifying join order in an execution plan
If the join order is not correct, check the statistics, cardinality & access
methods
1
2
3
Want to start with the table that
reduce the result set the most
4
5
50. It can be hard to determine Join Order for Complex SQL statements but it is easily
visible in the outline data of plan FORMAT=>’TYPICAL +outline’);
SELECT * FROM table(dbms_xplan.display_cursor(format=>’TYPICAL +OUTLINE'));
Finding the join order for complex SQL
The leading hint tells
you the join order
51. What causes the wrong join order
Causes
Incorrect single table cardinality estimates
Incorrect join cardinality estimates
52. What is an execution plan
Program Agenda
1
2
3
4
How to generate a plan
Understanding execution plans
• Cardinality
• Access paths
• Join methods
• Join order
Execution Plan Example
52
53. Example SQL Statement
SELECT e1.last_name, e1.job_title, e1.total_comp
FROM (SELECT e.manager_id, e.last_name, j.job_title,
e.salary+(e.salary+e.commission_pct) total_comp
FROM employees e, jobs j, departments d
WHERE d.department_name = 'Sales'
AND e.department_id = d.department_id
AND e.job_id = j.job_id ) e1,
(SELECT e.employee_id, e.salary+(e.salary+e.commission_pct) tc
FROM employees e, departments d
WHERE d.department_name = ‘Sales'
AND e.department_id = d.department_id ) e2
WHERE e1.manager_id = e2.employee_id
AND e1.total_comp >= e2.tc;
Find all the employees who make as much or more than their manager
54. Is it a good execution plan?
Means no stats gathered strong
indicator this won’t be best
possible plan
1. Is the estimated number of
rows being returned accurate?
2. Are the cardinality
estimates accurate?
3.Are the access
method correct?
55. Example cont’d execution plan
5. Is the join order correct? Is the table that
eliminates the most rows accessed first?
4. Are the right join methods being used?
1
2
3
4
5
56. What does the plan tree look like?
TABLE ACCESS
EMPLOYEES
TABLE ACCESS
DEPARTMENT
MERGE JOIN
CARTESIAN
TABLE ACCESS
EMPLOYEES
HASH JOIN
INDEX UNIQUE SCAN –
TABLE ACCESS
DEPARTMENT
NESTED LOOP INDEX UNIQUE SCAN –
TABLE ACCESS JOBS
NESTED LOOP
57. Solution
2. Cardinalities are correct and
with each join number of rows
reduced
1. Only 1 row is actually returned and the cost is 4
lower now
4. Join methods have
changed to be all NL
3. Access methods
have changed for
some tables
1
2
3
5. The join
order has
changed
5
4
58. What does the plan tree look like?
TABLE
ACCESS
DEPARTMENT
NESTED LOOP
INDEX UNIQUE SCAN –
TABLE ACCESS
DEPARTMENT
NESTED LOOP
INDEX UNIQUE SCAN -
TABLE ACCESS JOBS
NESTED LOOP
NESTED LOOP
INDEX RANGE SCAN –
TABLE ACCESS
EMPLOYEES
INDEX RANGE SCAN –
TABLE ACCESS
EMPLOYEES
59. 59
Related White Papers
• Explain the Explain Plan
• Understanding Optimizer Statistics
• Best Practices for Gathering Optimizer Statistics
•What to expect from the Optimizer in 19c
•What to expect from the Optimizer in 12c
• What to expect from the Optimizer in 11g
Join the Conversation
https://twitter.com/SQLMaria
https://blogs.oracle.com/optimizer/
https://sqlmaria.com
https://www.facebook.com/SQLMaria
Editor's Notes
Execution plans show the detailed steps necessary to execute a SQL statement
These steps are expressed as a set of database operators that consumes and produces rows
The order of the operators and their implementation is decided by the optimizer using a combination of query transformations and physical optimization techniques
The display is commonly shown in a tabular format, but a plan is in fact tree-shaped
Here are some additional resources. Join the conversation.