1 Chapter 8 Execution Plan Management. 2 Overview of Execution Plan Management Review techniques to – override optimizer – Improve optimizer’s decisions.

Slides:



Advertisements
Similar presentations
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Advertisements

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.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
15 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Memory.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
Optimization Exercises. Question 1 How do you think the following query should be computed? What indexes would you suggest to use? SELECT E.ename, D.mgr.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Oracle 11g Real Application Testing: Avoiding Performance Regressions with SQL Performance Analyzer Khaled Yagoub, Pete Belknap, Benoit Dageville, Karl.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
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.
By Lecturer / Aisha Dawood 1.  Administering Users  Create and manage database user accounts.  Create and manage roles.  Grant and revoke privileges.
Oracle PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
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.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
The Self-Managing Database: Guided Application and SQL Tuning Mohamed Ziauddin Consulting Member of Technical Staff Oracle Corporation Session id:
RBO RIP George Lumpkin Director Product Management Oracle Corporation Session id:
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.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
Database Programming Sections 11 & 12 – Creating, and Managing Views, Sequences, Indexes, and Synonymns.
SQL Performance and Optimization l SQL Overview l Performance Tuning Process l SQL-Tuning –EXPLAIN PLANs –Tuning Tools –Optimizing Table Scans –Optimizing.
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
Manipulating Data in PL/SQL. 2 home back first prev next last What Will I Learn? Construct and execute PL/SQL statements that manipulate data with DML.
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.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
INCLUDING CONSTRAINTS lecture5. Outlines  What are Constraints ?  Constraint Guidelines  Defining Constraint  NOT NULL constraint  Unique constraint.
6 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
Oracle 9i Release 2, A new set of tips, tricks and Techniques. Steve George Sr. Delivery Manager – Oracle University Oracle Corporation Session id: #32681.
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
Partition Architecture Yeon JongHeum
Chapter 5 Index and Clustering
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
1 Copyright © 2005, Oracle. All rights reserved. Following a Tuning Methodology.
10g Tuning Highlights Presenter JEREMY SCHNEIDER Senior Consultant, ITC Technology Services.
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
Session id: Darrell Hilliard Senior Delivery Manager Oracle University Oracle Corporation.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Module 5: Managing Content. Overview Publishing Content Executing Reports Creating Cached Instances Creating Snapshots and Report History Creating Subscriptions.
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Oracle9i Developer: PL/SQL Programming Chapter 6 PL/SQL Packages.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
D Copyright © 2009, Oracle. All rights reserved. Using SQL*Plus.
Table spaces.
SQL Trace and TKPROF.
How To Pass Oracle 1z0-060 Exam In First Attempt?
Using SQL*Plus.
Database Performance Tuning and Query Optimization
Using SQL*Plus.
Optimizer Plan Stability
Chapter 2 Views.
Chapter 2 Views.
Managing Privileges.
Chapter 11 Database Performance Tuning and Query Optimization
IST 318 Database Administration
Presentation transcript:

1 Chapter 8 Execution Plan Management

2 Overview of Execution Plan Management Review techniques to – override optimizer – Improve optimizer’s decisions Techniques discussed in this chapter are: – Hints – Stored Outlines – Creating Profiles – Utilizing baselines

3 Hints Instructions to guide optimizer Optimizer obliges even if inefficient Done within SELECT or DML statement Example: SELECT /+* FULL(customers) */ * FROM customers WHERE cust_year_of_birth = 1976 AND cust_gender = ‘F’ AND cust_marital_status = ‘single’;

4 Hints (cont.) Done to request particular access path – Request a full table scan – Request the use of an index – Request a particular type of join – Request the optimizer_mode for the query – Request parallelism – See common hints on pp Multiple hints can be used in one statement

5 More Hint Examples Requesting an index SELECT /+* index(e emp_manager_ix) */ employee_id, first_name, last_name FROM employees e WHERE manager_id = 100 AND department_id = 90; Requesting join order & type of join SELECT /+* ORDERED USE_HASH(e) */ * FROM departments d JOIN employees e USING (department_id); See pp for more examples

6 Errors in Hints Errors in hints generate no error Hints with errors are simply ignored Use of aliases in hint must match what is specified in SQL Validate use of hint using – DBMS_XPLAN – Autotrace – TKPROF

7 Stored Outlines Ensure that specific execution plan is used regardless of statistics Also known as “Plan Stability Advantages – Prevents runtime optimizer “bad execution plans” – Better than locking statistics / relevant only to given SQL – “Locks” execution plan and thus seen performance on SQL – Can be public or private Disadvantages – Does not take advantage of more current statistics – Will be deprecated in future release (see Baselines) – Public vs. private outline configuration a bit confusing

8 Stored Outlines (cont.) Example of candidate SQL statement – Performs well for clients – Does full-table scan – Has secondary index on cust_year_of_birth – Based on statistics, optimizer may decide to use index at any time (any run of the statement) – Regardless of what optimizer “thinks”, you want to lock the performance of this statement SELECT MAX(cust_income_level) FROM customers WHERE cust_year_of_birth >1985;

9 Stored Outlines (cont.) Example of outline to satisfy previous requirement – Create the outline CREATE OUTLINE customer_yob_qry FOR CATEGORY outlines 2 ON SELECT MAX(cust_income_level) FROM customers WHERE cust_year_of_birth >1985; – Enable the outline ALTER SESSION SET use_stored_outlines=outlines2; – Validate use of outline Via DBMS_XPLAN Autotrace

10 Stored Outlines (cont.) Hacking an outline to temporarily modify an execution plan (e.g. – you want to add a hint) – Use a private outline on top of a public outline CREATE PRIVATE OUTLINE original_oln FROM cust_yob_otln; CREATE PRIVATE OUTLINE hinted_oln ON SELECT /*+ INDEX(customers) */ MIN(cust_income_level) FROM customers WHERE cust_year_of_birth > 1985; ALTER SESSION SET use_private_outlines=TRUE; – See global temporary table OL$HINTS to see optimizer results for each private outline to analyze results

11 SQL Tuning Sets A group of SQL statements processed as group – Use with currently cached SQL – From SQL from Automatic Workload Repository – From a manual workload Processed by Oracle Tuning & Plan Management Create Tuning Sets – Manually using DBMS_SQLTUNE package – Via Enterprise Manager Need Tuning Pack license See SQL Tuning Advisor & SQL Access Advisor

12 SQL Profiles Contrast between Profiles and Outlines – Outline focuses on stability – Profiles focus on flexibility Associated with SQL Tuning Advisor – Known as a “offline optimizer” Advantages of SQL Tuning Advisor – Can spend more time optimizing SQL – Can partially run SQL before deciding on plan – Can create a profile for future use – Can be shared between logically similar statements

13 SQL Baselines Supplements SQL Profiles Will eventually replace stored outlines Provides mechanism to ensure plan improvement Offers flexibility and stability – Ensures a plan will not be degraded by inferior plan Create via DBMS_SPM package Can be viewed via DBA_SQL_PLAN_BASELINES

14 SQL Baselines (cont.) Controlled via parameters – OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES – OPTIMIZER_USE_SQL_PLAN_BASELINES Evolving a baseline over time – Optimizer lets humans decide on a proposed change – Subsequent superior plans are: stored as “unaccepted” in DBA_SQL_PLAN_BASELINES view not used until “verified” – Verification manual via EVOLVE_SQL_PLAN_BASELINE procedure Baselines can be configured in Enterprise Manager