© 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle 9.0.1  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include.

Slides:



Advertisements
Similar presentations
Maria Colgan & Thierry Cruanes
Advertisements

12 Copyright © 2005, Oracle. All rights reserved. Query Rewrite.
1.
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Introduction to SQL Tuning Brown Bag Three essential concepts.
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
© Bharati Vidyapeeths Institute of Computer Applications and Management, New Delhi © Bharati Vidyapeeths Institute of Computer Applications and.
Copyright © 2003, SAS Institute Inc. All rights reserved. SAS is a registered trademark or trademark of SAS Institute Inc. in the USA and other countries.
What Happens when a SQL statement is issued?
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
1 © 2006 Julian Dyke Supplemental Logging Julian Dyke Independent Consultant juliandyke.com Web Version.
© Hortonworks Inc Daniel Dai Thejas Nair Page 1 Making Pig Fly Optimizing Data Processing on Hadoop.
CS 540 Database Management Systems
EXECUTION PLANS By Nimesh Shah, Amit Bhawnani. Outline  What is execution plan  How are execution plans created  How to get an execution plan  Graphical.
Prligence Empowering Intelligence All About Fine Grained Access Control by Arup Nanda.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential.
9 Copyright © Oracle Corporation, All rights reserved. Oracle Recovery Manager Overview and Configuration.
Module 14: Scalability and High Availability. Overview Key high availability features available in Oracle and SQL Server Key scalability features available.
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
SQL Server Query Optimizer Cost Formulas Joe Chang
Oracle Database 12c is the latest version of Oracle Corporations flagship database and has added many new features. In this presentation I am capturing.
AN INTRODUCTION TO EXECUTION PLAN OF QUERIES These slides have been adapted from a presentation originally made by ORACLE. The full set of original slides.
SQL Tuning Ohio Oracle User’s Group October 2002 © Copyright, Kris T. Mason, 2002.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
1 Forgotten Features Julian Dyke Independent Consultant Web Version juliandyke.com © 2005 Julian Dyke.
© 2010 IBM Corporation Information Management Performance Enhancements for DB2 V10.1 Anthony Reina - Accelerated Value Specialist
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Access Path Selection in a Relational Database Management System Selinger et al.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
CPS216: Advanced Database Systems Notes 07:Query Execution Shivnath Babu.
1 Chapter 7 Optimizing the Optimizer. 2 The Oracle Optimizer is… About query optimization Is a sophisticated set of algorithms Choosing the fastest approach.
Administration and Monitoring the Database Oracle 10g.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Data Warehouse Design Xintao Wu University of North Carolina at Charlotte Nov 10, 2008.
Parallel Execution Plans Joe Chang
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
Oracle tuning: a tutorial Saikat Chakraborty. Introduction In this session we will try to learn how to write optimized SQL statements in Oracle 8i We.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
Query Optimizer Execution Plan Cost Model Joe Chang
Oracle Database Performance Secrets Finally Revealed Greg Rahn & Michael Hallas Oracle Real-World Performance Group Server Technologies.
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
Chapter 4 Logical & Physical Database Design
J.NemecAre Your Statistics Bad Enough?1 Verify the effectiveness of gathering optimizer statistics Jaromir D.B. Nemec UKOUG
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
2 Copyright © 2006, Oracle. All rights reserved. Configuring Recovery Manager.
Query Processing – Implementing Set Operations and Joins Chap. 19.
SQL Query Generator User Interface Analyzer Logger DB Manager Grammar Test Framework Embedded DB Random Query GeneratorMulti DB Query Result AnalyzerAnalysis.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Session Name Pelin ATICI SQL Premier Field Engineer.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
SQL Server Statistics and its relationship with Query Optimizer
Query Optimization Techniques
EXPLAIN and AUTOTRACE.
Scaling SQL with different approaches
Query Tuning without Production Data
Physical Join Operators
Presentation transcript:

© 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include  Access Predicates (Joins)  Filter Predicates  Related views include  V$SQL_PLAN_WORKAREA  V$SQL_PLAN_STATISTICS  V$SQL_PLAN_STATISTICS_ALL

© 2005 Julian Dyke juliandyke.com 2 V$SQL_PLAN ADDRESSRAW(4) HASH_VALUENUMBER CHILD_NUMBERNUMBER OPERATIONVARCHAR2(30) OPTIONSVARCHAR2(30) OBJECT_NODEVARCHAR2(10) OBJECT#NUMBER OBJECT_OWNERVARCHAR2(30) OBJECT_NAMEVARCHAR2(64) OPTIMIZERVARCHAR2(20) IDNUMBER PARENT_IDNUMBER DEPTHNUMBER POSITIONNUMBER COSTNUMBER CARDINALITYNUMBER BYTESNUMBER OTHER_TAGVARCHAR(35) PARTITION_STARTVARCHAR2(5) PARTITION_STOPVARCHAR2(5) PARTITION_IDNUMBER OTHERVARCHAR2(4000) DISTRIBUTIONVARCHAR2(20) CPU_COSTNUMBER IO_COSTNUMBER TEMP_SPACENUMBER ACCESS_PREDICATESVARCHAR2(4000) FILTER_PREDICATESVARCHAR2(4000) PROJECTIONVARCHAR2(4000) TIMENUMBER QBLOCK_NAMEVARCHAR2(31) REMARKSVARCHAR2(4000)

© 2005 Julian Dyke juliandyke.com 3 Optimizer Environment Variables  In Oracle 10.1 and above, optimizer environment variables are externalized at :  instance level - V$SYS_OPTIMIZER_ENV  session level - V$SES_OPTIMIZER_ENV  statement level - V$SQL_OPTIMIZER_ENV  Use the values in these views when determining why execution plans differ

© 2005 Julian Dyke juliandyke.com 4 Optimizer Environment Variables  Optimizer Environment Variable values reported by the dynamic performance views include: active_instance_countparallel_dml_mode bitmap_merge_area_sizeparallel_execution_enabled cpu_countparallel_query_mode cursor_sharingparallel_threads_per_cpu db_file_multiblock_read_countpga_aggregate_target hash_area_sizequery_rewrite_enabled optimizer_dynamic_samplingquery_rewrite_integrity optimizer_features_enableskip_unusable_indexes optimizer_index_cachingsort_area_retained_size optimizer_index_cost_adjsort_area_size optimizer_modestar_transformation_enabled optimizer_mode_hintedstatistics_level parallel_ddl_modeworkarea_size_policy

© 2005 Julian Dyke juliandyke.com 5 DBMS_XPLAN  Introduced in Oracle 9.2  Formats PLAN_TABLE contents generated by EXPLAIN PLAN SELECT * FROM TABLE (dbms_xplan.display);  DISPLAY function parameters include  TABLE_NAME – name of plan table  STATEMENT_ID – statement ID in plan table  FORMAT – as below ValueDescription BASICOperation ID, object name and operation/option only TYPICAL(Default) Most relevant information including partition pruning, parallelism and predicates where appropriate ALLAs TYPICAL plus parallel execution server statements SERIALAs TYPICAL without parallel execution server statements

© 2005 Julian Dyke juliandyke.com 6 DBMS_XPLAN  For example explain a query EXPLAIN PLAN FOR SET STATEMENT_ID = 'STATEMENT1' FOR SELECT t1.c2, t2.c2 FROM t1, t2 WHERE t1.c1 = t2.c1 AND t1.c2 = 10; SELECT * FROM TABLE ( dbms_xplan.display ('PLAN_TABLE','STATEMENT1') );  The plan table can be queried using

© 2005 Julian Dyke juliandyke.com 7 DBMS_XPLAN  Example output with predicates IdOperationNameRowsBytesCost 0SELECT STATEMENT * 1HASH JOIN * 2TABLE ACCESS FULLT TABLE ACCESS FULLT Predicate Information (identified by operation id): 1 - access("T1"."C1"="T2"."C1") 2 - filter("T1"."C2"=10)

© 2005 Julian Dyke juliandyke.com 8 DBMS_XPLAN  Parallel execution queries are automatically formatted e.g. EXPLAIN PLAN FOR SELECT /*+ ORDERED PARALLEL (t1 2) USE_MERGE (t1 t2) */ t1.c2, t2.c2 FROM t1, t2 WHERE t1.c1 = t2.c1 AND t1.c2 = 10; SELECT * FROM TABLE (dbms_xplan.display);  The plan table can be queried using

© 2005 Julian Dyke juliandyke.com 9 DBMS_XPLAN  Example output for parallel execution IdOperationNameRowsBytesCostTQIN-OUTPQ Distrib 0SELECT STATEMENT MERGE JOIN ,02P->SQC(RANDOM) 2SORT JOIN ,02PCWP * 3TABLE ACCESS FULLT ,01P->PHASH * 4SORT JOIN ,02PCWP 5TABLE ACCESS FULLT ,00S->PHASH Predicate Information (identified by operation id): 3 - filter("T1"."C2"=10) 4 - access("T1"."C1"="T2"."C1") filter("T1"."C1"="T2"."C1")

© 2005 Julian Dyke juliandyke.com 10 DBMS_XPLAN  Partition pruning information can also be included e.g. for a range partitioned table EXPLAIN PLAN FOR SELECT c2 FROM t1 WHERE c1 >= 150 AND c1 < 250; CREATE TABLE t1 (c1 NUMBER,c2 NUMBER,c3 CHAR(50)) PARTITION BY RANGE (c1) ( PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN (200), PARTITION p3 VALUES LESS THAN (300), PARTITION p4 VALUES LESS THAN (400) ); SELECT * FROM TABLE (dbms_xplan.display);

© 2005 Julian Dyke juliandyke.com 11 DBMS_XPLAN  Example output for partition pruning IdOperationNameRowsBytesCostPStartPStop 0SELECT STATEMENT1262 1PARTITION RANGE ITERATOR23 * 2TABLE ACCESS FULLT Predicate Information (identified by operation id): 2 - filter("T1"."C1">=150 AND "T1"."C1"<250)