Interpreting Explain Plan Output. John Mullins

Similar documents
What do you mean the Oracle Optimizer won't use my Index? John Mullins

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins

Oracle PL/SQL Best Practices Part 1. John Mullins

Troubleshooting Oracle PL/SQL with DBMS_PROFILER and DBMS_UTILITY. John Mullins

Oracle 9i Application Development and Tuning

Oracle Database 11g: SQL Tuning Workshop

Answer: Reduce the amount of work Oracle needs to do to return the desired result.

7. Query Processing and Optimization

ORACLE TRAINING CURRICULUM. Relational Databases and Relational Database Management Systems

The Oracle Optimizer Explain the Explain Plan O R A C L E W H I T E P A P E R A P R I L

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Oracle DB-Tuning Essentials

Oracle Database Performance Tuning, Benchmarks & Replication

Advanced Oracle SQL Tuning v3.0 by Tanel Poder

Oracle Database 11g: SQL Tuning Workshop. Student Guide

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

Performance Optimization for Informatica Data Services ( Hotfix 3)

Physical Design. Elena Baralis, Silvia Chiusano Politecnico di Torino. Phases of database design D B M G. Database Management Systems. Pag.

Join Methods. Franck Pachot CERN

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

Suppose we need to get/retrieve the data from multiple columns which exists in multiple tables...then we use joins..

Architettura Database Oracle

Oracle SQL Tuning for Developers Workshop Student Guide - Volume I

ORACLE DATABASE 12C INTRODUCTION

Exploring Best Practices and Guidelines for Tuning SQL Statements

Table of Contents. Oracle SQL PL/SQL Training Courses

20761 Querying Data with Transact SQL

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables)

Oracle Database 11gR2 Optimizer Insights

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

Scaling To Infinity: Making Star Transformations Sing. Thursday 15-November 2012 Tim Gorman

D B M G Data Base and Data Mining Group of Politecnico di Torino

DB2 SQL for the 21 st Century: Overlooked Enhancements. David Simpson

Course Contents of ORACLE 9i

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Outline. Database Management and Tuning. Outline. Join Strategies Running Example. Index Tuning. Johann Gamper. Unit 6 April 12, 2012

<Insert Picture Here> DBA s New Best Friend: Advanced SQL Tuning Features of Oracle Database 11g

Oracle Database 12c: SQL Tuning for Developers

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

CS330. Query Processing

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

DB2 9 for z/os Selected Query Performance Enhancements

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Query Optimizer MySQL vs. PostgreSQL

Ensuring Optimal Performance. Vivek Sharma. 3 rd November 2012 Sangam 2012

Applying a Blockcentric Approach to Oracle Tuning. Daniel W. Fink

Evaluation of Relational Operations

Overview of Query Evaluation. Overview of Query Evaluation

Infrastructure at your Service. In-Memory-Pläne für den 12.2-Optimizer: Teuer oder billig?

Query Optimizer MySQL vs. PostgreSQL

Components of a DMBS

Overview of Implementing Relational Operators and Query Evaluation

Join (SQL) - Wikipedia, the free encyclopedia

SQL (Structured Query Language)

Estimating Cardinality: Use of Jonathan Lewis CBO methodology

Outline. Database Tuning. Join Strategies Running Example. Outline. Index Tuning. Nikolaus Augsten. Unit 6 WS 2014/2015

Sql Server Syllabus. Overview

Oracle Database 10g: Introduction to SQL

Oracle Hints. Using Optimizer Hints

Real-World Performance Training SQL Performance

New Requirements. Advanced Query Processing. Top-N/Bottom-N queries Interactive queries. Skyline queries, Fast initial response time!

Query Evaluation Overview, cont.

Database Performance Tuning and Query Optimization

ENHANCING DATABASE PERFORMANCE

Query Optimization, part 2: query plans in practice

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

Evaluation of Relational Operations: Other Techniques. Chapter 14 Sayyed Nezhadi

AVANTUS TRAINING PTE LTD

Query Evaluation and Optimization

Faloutsos 1. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Outline

SQL Tuning Reading Recent Data Fast

Evaluation of Relational Operations: Other Techniques

Outline. Query Types

Oracle Syllabus Course code-r10605 SQL

[AVNICF-MCSASQL2012]: NICF - Microsoft Certified Solutions Associate (MCSA): SQL Server 2012

THE OPTIMIZATION OF DATA ACCESS USING JOIN CLAUSE

Querying Data with Transact-SQL

Relational Database Index Design and the Optimizers

Querying Microsoft SQL Server 2008/2012

SQL Tuning via Toad Tips for Optimizing SQL Performance

EDUVITZ TECHNOLOGIES

Hash-Based Indexing 165

Real-World Performance Training SQL Performance

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag.

Oracle 1Z0-054 Exam Questions and Answers (PDF) Oracle 1Z0-054 Exam Questions 1Z0-054 BrainDumps

Course Outline and Objectives: Database Programming with SQL

Query Evaluation Overview, cont.

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing

Optimizer with Oracle Database 12c Release 2 O R A C L E W H I T E P A P E R J U N E

Data Warehouse Tuning. Without SQL Modification

Evaluation of Relational Operations: Other Techniques

Querying Data with Transact SQL

Query Processing. Solutions to Practice Exercises Query:

OpenWorld 2018 SQL Tuning Tips for Cloud Administrators

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Administrivia. Administrivia. Faloutsos/Pavlo CMU /615

Oracle DB-Tuning Essentials

And Answers In Oracle Pl Sql

Fundamentals of Database Systems

Querying Data with Transact-SQL

QUERY OPTIMIZATION [CH 15]

Transcription:

Interpreting Explain Plan Output John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars

Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 30+ years of Oracle experience Oracle Certified Professional DBA Certified Technical Trainer Over 250 classes taught

Themis Inc. More than 18 years in the industry Committed to your training Courses: DB2, SQL Server, Oracle, Unix, Linux, Java, Web Development,.NET and many more www.themisinc.com

Related / Upcoming Themis Classes Oracle SQL Optimization Introduction to Oracle SQL Oracle Advanced SQL

Webinar Objectives Gain an understanding of how to interpret the output generated by the Explain Plan utility

Explain Plan Overview An explain plan is a representation of the access path that is taken when a query is executed within Oracle. The explain plan is produced by the optimizer. Once the access path has been decided upon it is stored in the library cache memory structure together with the statement itself.

Reading Explain Plan Output Read from the inside out Read from the top down --------------------------------------------------------------------------------------------------- Id Operation Name Rows Bytes Cost (%CPU) Time --------------------------------------------------------------------------------------------------- 0 SELECT STATEMENT 10 570 7 (15) 00:00:01 * 1 HASH JOIN 10 570 7 (15) 00:00:01 2 NESTED LOOPS 3 NESTED LOOPS 10 380 4 (0) 00:00:01 * 4 TABLE ACCESS FULL DEPARTMENT 1 16 3 (0) 00:00:01 * 5 INDEX RANGE SCAN EMP_DEPARTMENT_IX 10 0 (0) 00:00:01 6 TABLE ACCESS BY INDEX ROWID EMPLOYEE 10 220 1 (0) 00:00:01 7 VIEW index$_join$_114 107 2033 3 (34) 00:00:01 * 8 HASH JOIN 9 INDEX FAST FULL SCAN EMP_NAME_IX 107 2033 1 (0) 00:00:01 10 INDEX FAST FULL SCAN EMP_EMP_ID_PK 107 2033 1 (0) 00:00:01 --------------------------------------------------------------------------------------------------- The order of the operations is 4, 5, 3, 6, 2, 9, 10, 8, 7, 1, 0.

What to Look For FULL Table Scans Join Methods, Join Order Index Access Methods Filters Parallel Operations Partition Processing Dynamic Statistics Cost

FULL Table Scans The entire table is read up to the high water mark (HWM). The HWM marks the last block in the table that has ever had data written to it. If you have deleted all the rows in a table you will still read up to the HWM.

Join Methods, Join Order Nested Loop Hash Join Sort Merge Join Cartesian Join

Nested Loop First we return all the rows from row source 1 (Driving Table), typically the smaller of the two row sources. Then we probe row source 2 (Inner Table) once for each row returned from row source 1. Good for joining smaller row sources. Best used with indexed foreign key columns.

Hash Join Smallest row source is chosen and used to build a hash table (in memory) and a bitmap. The second row source is hashed and checked against the hash table looking for joins. The bitmap is used as a quick lookup to check if rows are in the hash table. Good for joining larger row sources. Needs PGA memory.

Sort Merge Join Rows are produced by row source 1 and are then sorted. Rows from row source 2 are then produced and sorted by the same sort key as Row Source 1. Row source 1 and 2 are NOT accessed concurrently. Sorted rows from both sides are then merged together. Needs PGA Memory.

Cartesian Join Every row from one row source is joined to every row from the second row source. Usually the result of a poorly written join.

Index Access Methods Index Range Scan Index Unique Scan Index Full Scan Index Fast Full Scan Index Skip Scan

Index Range Scan Method for accessing multiple column values. A non-unique index may return multiple values for the predicate col1 = n and will use an index range scan. TABLE ACCESS BY ROWID EMP INDEX RANGE SCAN EMP_IX1

Index Unique Scan Method for looking up a single key value via a unique index. Always returns a single value. TABLE ACCESS BY ROWID EMP INDEX UNIQUE SCAN EMP_IX0

Index Full Scan In certain circumstances it is possible for the whole index to be scanned where no constraining predicates are provided for a table. An index full scan will perform single block i/o's and so it may prove to be inefficient. SELECT STATEMENT INDEX FULL SCAN EMP_IX2

Index Fast Full Scan Scans all the block in the index Rows are not returned in sorted order. Uses multiblock i/o and can be executed in parallel. SELECT STATEMENT INDEX FAST FULL SCAN EMP_IX3

Index Skip Scan The optimizer can perform skip scans to retrieve rowids for values that do not use the prefix of a concatenated index. Initiated by probing the index for distinct values of the prefix column. Each of these distinct values is then used as a starting point for a regular index search. SELECT STATEMENT INDEX SKIP SCAN EMP_IX4

Filters Restrictions in the WHERE clause. Optimizer will try to filter rows before performing joins and this is the goal. --------------------------------------------------------------------------- Id Operation Name Rows Bytes Cost (%CPU) Time --------------------------------------------------------------------------- 0 SELECT STATEMENT 5 110 6 (0) 00:00:01 * 1 HASH JOIN 5 110 6 (0) 00:00:01 * 2 TABLE ACCESS FULL DEPT 1 13 3 (0) 00:00:01 * 3 TABLE ACCESS FULL EMP 5 45 3 (0) 00:00:01 --------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("d"."deptno"="e"."deptno") 2 - filter("d"."deptno"=20) 3 - filter("e"."deptno"=20)

Parallel Operations Some SQL processing can be broken into separate parallel processing steps. Parallel processing can be hinted. Some operations that might be seen in the execution plan: PX COORDINATOR PX BLOCK ITERATOR PX SEND PX RECEIVE

Partition Processing Common practice to partition tables that are expected to contain a large volume of rows. The optimizer is partition-smart, and its plans should reflect this. (Partition Pruning) Partition access in the execution plan: PARTITION LIST SINGLE PARTITION LIST ALL

Dynamic Statistics Indicates object statistics are missing. Oracle 12c Example: -------------------------------------------------------------------------- Id Operation Name Rows Bytes Cost (%CPU) Time -------------------------------------------------------------------------- 0 SELECT STATEMENT 5 445 3 (0) 00:00:01 * 1 TABLE ACCESS FULL EMP 5 445 3 (0) 00:00:01 -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 1 - filter("deptno"=20) Note ----- - dynamic statistics used: dynamic sampling (level=2)

What to Look For Cost Represents the estimated resource usage for a plan. The optimizer s cost model accounts for the IO, CPU, and network resources that will be used by the query. Cost for an entire plan is indicated on line 0 of the explain plan output. Used to compare different plans for the same query.

Summary There are many things to look for in an execution plan for an SQL statement Questions? jmullins@themisinc.com

Themis Oracle Classes Classes are offered in a public classroom, onsite at your location, or live on the internet Oracle SQL Optimization Oracle SQL, Oracle Advanced SQL Oracle PL/SQL, Oracle Advanced PL/SQL Oracle Database Performance Tuning for Administrators And many more

For More Information Visit the Themis web site www.themisinc.com John Caccavale jcac@themisinc.com 908-233-8900 To get a copy of the presentation: http://www.themisinc.com/webinars Thank you for attending. Have a good day.