When Good Optimizers Make Bad Choices (Sometimes) March, 2005 ©2005 Dan Tow All rights reserved SingingSQL Presents.

Slides:



Advertisements
Similar presentations
Youre Smarter than a Database Overcoming the optimizers bad cardinality estimates.
Advertisements

Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Query Optimization Reserves Sailors sid=sid bid=100 rating > 5 sname (Simple Nested Loops) Imperative query execution plan: SELECT S.sname FROM Reserves.
Natural Data Clustering: Why Nested Loops Win So Often May, 2008 ©2008 Dan Tow, All rights reserved SingingSQL.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Using the Optimizer to Generate an Effective Regression Suite: A First Step Murali M. Krishna Presented by Harumi Kuno HP.
Query Optimization CS634 Lecture 12, Mar 12, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
SQL Performance 2011/12 Joe Chang, SolidQ
Data Mining Methodology 1. Why have a Methodology  Don’t want to learn things that aren’t true May not represent any underlying reality ○ Spurious correlation.
Database Management Systems 3ed, R. Ramakrishnan and Johannes Gehrke1 Evaluation of Relational Operations: Other Techniques Chapter 14, Part B.
Database Management Systems, R. Ramakrishnan and Johannes Gehrke1 Evaluation of Relational Operations: Other Techniques Chapter 12, Part B.
Slide: 1 Presentation Title Presentation Sub-Title Copyright 2010 Robert Haas, EnterpriseDB Corporation. Creative Commons 3.0 Attribution. The PostgreSQL.
Recent-Rows-First Case Study February, 2010 ©2010 Dan Tow, All rights reserved SingingSQL Presents SingingSQL.
1 Relational Query Optimization Module 5, Lecture 2.
Query Optimization 3 Cost Estimation R&G, Chapters 12, 13, 14 Lecture 15.
Tirgul 7. Find an efficient implementation of a dynamic collection of elements with unique keys Supported Operations: Insert, Search and Delete. The keys.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
16.5 Introduction to Cost- based plan selection Amith KC Student Id: 109.
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.
The query processor does what the query plan tells it to do A “good” query plan is essential for a well- performing.
Relational Database Performance CSCI 6442 Copyright 2013, David C. Roberts, all rights reserved.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
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.
Lecture 8 Index Organized Tables Clusters Index compression
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Query Evaluation Chapter 12: Overview.
Getting SQL Right the First Try (Most of the Time!) May, 2008 ©2007 Dan Tow, All rights reserved SingingSQL Presents.
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.
Database Management 9. course. Execution of queries.
Query optimization in relational DBs Leveraging the mathematical formal underpinnings of the relational model.
Data Structures & Algorithms and The Internet: A different way of thinking.
RBO RIP George Lumpkin Director Product Management Oracle Corporation Session id:
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Query Optimization March 10 th, Very Big Picture A query execution plan is a program. There are many of them. The optimizer is trying to chose a.
Star Transformations Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
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.
Module 4 Database SQL Tuning Section 3 Application Performance.
Introduction to Query Optimization, R. Ramakrishnan and J. Gehrke 1 Introduction to Query Optimization Chapter 13.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Introduction to Query Optimization Chapter 13.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Chapter 5 Index and Clustering
Query Processing – Implementing Set Operations and Joins Chap. 19.
for all Hyperion video tutorial/Training/Certification/Material Essbase Optimization Techniques by Amit.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently and safely. Provide.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
The PostgreSQL Query Planner Robert Haas PostgreSQL East 2010.
How is data stored? ● Table and index Data are stored in blocks(aka Page). ● All IO is done at least one block at a time. ● Typical block size is 8Kb.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
Query Optimization Techniques
Query Tuning without Production Data
CS222P: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Chapter 12: Query Processing
Database Performance Tuning and Query Optimization
Introduction to Query Optimization
Evaluation of Relational Operations: Other Operations
File Processing : Query Processing
Chapter 11 Database Performance Tuning and Query Optimization
Evaluation of Relational Operations: Other Techniques
Introduction to the Optimizer
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Evaluation of Relational Operations: Other Techniques
Performance Tuning ETL Process
Presentation transcript:

When Good Optimizers Make Bad Choices (Sometimes) March, 2005 ©2005 Dan Tow All rights reserved SingingSQL Presents SingingSQL Presents:

Overview Introduction – the Nature of the Game The CBO versus the Human “Player” Choices Unavailable to the CBO Objections to Human Tuning, Addressed

Introduction – The Nature of the Game Think of tuning as a game (“Deep Blue” versus Kasparov?): What advantages does the CBO have, versus a human “player” (tuner)? –Ability to crunch lots of numbers, well, to explore many options. What disadvantages does the CBO have? –Very little time to optimize. –Limited information. –Fewer options (different, more-limiting rules than apply to a human player). –Less strategic sophistication than a good human tuner.

Overview Introduction – the Nature of the Game The CBO versus the Human “Player” Choices Unavailable to the CBO Objections to Human Tuning, Addressed

Reasons the CBO Misses Good Choices CBO is not allowed to execute queries to test alternative plans, or to learn more about selectivities than its best guess from statistics (optimizer_dynamic_sampling offers an exception to this rule, though!) CBO searches a tiny fraction of all possible plans, for truly complex SQL, and applies a limited strategy to prune the search. CBO cost function imperfectly predicts the relative costs of alternative plans. CBO lacks insight into the freedom to change corner-case behavior.

Unfair Advantages Humans Enjoy CBO is not allowed to execute queries to test alternative plans, or to learn more about selectivities than its best guess from statistics: While the CBO must try to optimize every query, the human can focus on a couple of dozen queries. We can test alternatives as long as necessary and only choose alternatives that we prove to be faster. With proven, tested performance of a chosen alternative, a human need never lose (although we may “tie” with the CBO).

Unfair Advantages Humans Enjoy CBO searches a tiny fraction of all possible plans, for truly complex SQL, and applies a limited strategy to prune the search: An informed human understanding of the tuning problem is much deeper, enabling more sophisticated strategies to locate the optimum, or a near-optimum, in a huge search space. Kasparov can (sometimes) beat even the brute force of Deep Blue with a superior understanding of strategy, and SQL optimization, so far, favors humans more than chess does.

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans. The cost function really has two parts: It predicts how many index entries, table rows, and blocks of every object the execution plan will reach during execution – this is the logical cost.

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans. The cost function really has two parts: From the logical cost, it must estimate a physical cost, which is mostly just the runtime, but weighted, potentially, in favor of plans that avoid bottlenecks that harm other processes.

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans. The cost function really has two parts, logical and physical cost estimation: A bad logical cost estimate almost guarantees a bad physical cost estimate (often by orders of magnitude!). However, even a good logical cost estimate does not guarantee a good physical cost estimate.

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans. Logical costs: Even with perfect statistics, the selectivity of a complex filter is impossible to predict, and filter selectivities are the main determiner of logical costs. Humans need not predict – we can measure! This is a huge advantage!

Selectivity-Error Examples test1 1 SELECT count(Data_Col) FROM DTow_Talk_Child 2* WHERE Date_Col >= TO_DATE('2005/01/01','YYYY/MM/DD')-10.1 SELECT STATEMENT c=196, R=1..2 SORT AGGREGATE c=_, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=196, R= INDEX RANGE SCAN DTOW_TALK_CHILD_DATE_COL: Date_Col c=27, R= ; COUNT(DATA_COL)

Selectivity-Error Examples test2 1 SELECT count(Data_Col) FROM DTow_Talk_Child 2 WHERE Date_Col >= TO_DATE('2005/01/01','YYYY/MM/DD')-10 3* AND Code_Col = 'OP'.1 SELECT STATEMENT c=7, R=1..2 SORT AGGREGATE c=_, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=7, R= INDEX RANGE SCAN DTOW_TALK_CHILD_CODE_COL: CODE_COL c=1, R= ; COUNT(DATA_COL) Elapsed: 00:00:00.14

Selectivity-Error Examples test3 1 SELECT count(Data_Col) FROM DTow_Talk_Child 2 WHERE Date_Col <= TO_DATE('2005/01/01','YYYY/MM/DD')-90 3* AND Code_Col = 'OP'.1 SELECT STATEMENT c=7, R=1..2 SORT AGGREGATE c=_, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=7, R= INDEX RANGE SCAN DTOW_TALK_CHILD_CODE_COL: CODE_COL c=1, R= ; COUNT(DATA_COL)

Dynamic Sampling in the CBO Dynamic sampling allows the CBO to sample application data at parse time to better estimate selectivities. Dynamic sampling is not the default, except low-level sampling where stats are wholly missing. Dynamic sampling slows parsing and sometimes prevents wrong optimizer choices. It can be activated for the system, the session, or with individual hints.

Now Try Dynamic Sampling! SQL> alter session set optimizer_dynamic_sampling=9; Elapsed: 00:00:00.07 test2 1 SELECT count(Data_Col) FROM DTow_Talk_Child 2 WHERE Date_Col >= TO_DATE('2005/01/01','YYYY/MM/DD')-10 3* AND Code_Col = 'OP'.1 SELECT STATEMENT c=7, R=1..2 SORT AGGREGATE c=_, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=7, R= INDEX RANGE SCAN DTOW_TALK_CHILD_CODE_COL: CODE_COL c=1, R=4600 COUNT(DATA_COL) Elapsed: 00:00:00.59

Dynamic Sampling SQL> alter session set optimizer_dynamic_sampling=9; COUNT(DATA_COL) Elapsed: 00:00:00.59 Compare this with default optimizer_dynamic_sampling=1! 4 ; COUNT(DATA_COL) Elapsed: 00:00:00.14

Dynamic Sampling Trade-offs In the example, level-9 dynamic sampling still mis- estimated the selectivity of the combined conditions by 22%, did not change the execution plan, and made the parse take 350ms longer. In general, dynamic sampling (even at level 10!) is a great tool for automatically generating potentially- improved execution plans, but higher across-the-board parsing costs explain why this is not the default!

Dynamic Sampling – Having Your Cake and Eating it, Too The cost of dynamic sampling is not a problem for a one-time tuning exercise, but why pay the cost at every parse? Use dynamic sampling to generate more-informed cost-based optimization during the tuning exercise. If the result is great performance, then you’re done, without figuring out the best plan, yourself. Use hints to force the great plan (found in the one- time tuning exercise) without recurring costs for dynamic sampling at every parse! This is like getting Deep Blue to choose your move!

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans. Physical costs: Relative CPU times for different sort of logical I/O vary widely, in hard-to-predict ways. Hit ratios of the different objects involved in SQL execution vary widely, in hard-to-predict ways. Humans need not predict – we can measure! We can even measure physical costs without knowing logical costs! This is a huge advantage!

Unfair Advantages Humans Enjoy CBO cost function imperfectly predicts the relative costs of alternative plans: Humans need not predict – we can measure! This is the moral equivalent to being allowed to “take back” moves in a game of chess, as many moves as we want, as often as we want, as we learn the consequences of those moves. This is a colossal advantage!

Measurement Example 7 … FROM DTow_Talk_Child C, -- 8 DTow_Talk_Parent1 P, --This plan is unchanged by 9 DTow_Type TC, --dynamic sampling!!! 10 DTow_Type TP 11 WHERE C.FKey1_ID=P.PKey_ID 12 AND C.Type_ID=TC.Type_ID 13 AND P.Type_ID=TP.Type_ID 14* and TC.Description='VERY_RARE'.1 SELECT STATEMENT c=3023, R=1..2 SORT AGGREGATE c=_, R=1...3 HASH JOIN c=3023, R= TABLE ACCESS FULL 4*DTOW_TYPE c=2, R= HASH JOIN c=3020, R= TABLE ACCESS FULL 2*DTOW_TALK_PARENT1 c=250, R= HASH JOIN c=2559, R= TABLE ACCESS BY INDEX ROWID 3*DTOW_TYPE c=2, R= INDEX RANGE SCAN DTOW_TYPE_DESCRIPTION: DESCRIPTION c=1, R= TABLE ACCESS FULL 1*DTOW_TALK_CHILD c=2555, R=

Measurement Example SESSION_ID Oracle_PID Client_PID Elapsed: 00:00: ; CDATE PDATE TCDESC TPDESC Elapsed: 00:00:01.14 LIO PIO Logical Reads = Physical Reads = 0

Measurement Example test6 1 select count(*) from (SELECT /*+ first_rows */ …rownum rn 8 FROM …-- 16* AND TC.Description='VERY_RARE').1 SELECT STATEMENT c=300252, R=1..2 SORT AGGREGATE c=_, R=1...3 VIEW 1* c=300252, R= COUNT c=_, R=_ TABLE ACCESS BY INDEX ROWID 2*DTOW_TALK_CHILD c=3, R= NESTED LOOPS c=300252, R= NESTED LOOPS c=252, R= MERGE JOIN CARTESIAN c=252, R= TABLE ACCESS BY INDEX ROWID 4*DTOW_TYPE c=2, R= INDEX RANGE SCAN DTOW_TYPE_DESCRIPTION: DESCRIPTION c=1, R= BUFFER SORT c=250, R= TABLE ACCESS FULL 3*DTOW_TALK_PARENT1 c=250, R= INDEX UNIQUE SCAN DTOW_TYPE_UNQ1: type_id c=_, R= INDEX RANGE SCAN DTOW_TALK_CHILD_FKEY1_ID: fkey1_id c=2, R=10

Measurement Example SESSION_ID Oracle_PID Client_PID Elapsed: 00:00: FIRST_ROWS plan 17 ; COUNT(*) Elapsed: 00:00:03.60 LIO PIO Logical Reads = Physical Reads = 0

Measurement Example test7 1 SELECT /*+ leading(TC) use_nl(C P) index(C DTOW_TALK_CHILD_TYPE_ID) 2 index(P DTOW_TALK_PARENT1_UNQ1) */ … --<Otherwise just like test4.sql 15* and TC.Description='VERY_RARE'.1 SELECT STATEMENT c=340711, R=1..2 SORT AGGREGATE c=_, R=1...3 HASH JOIN c=340711, R= NESTED LOOPS c=340470, R= NESTED LOOPS c=7137, R= TABLE ACCESS BY INDEX ROWID 3*DTOW_TYPE c=2, R= INDEX RANGE SCAN DTOW_TYPE_DESCRIPTION: DESCRIPTION c=1, R= TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=7135, R= INDEX RANGE SCAN DTOW_TALK_CHILD_TYPE_ID: type_id c=843, R= TABLE ACCESS BY INDEX ROWID 2*DTOW_TALK_PARENT1 c=1, R= INDEX UNIQUE SCAN DTOW_TALK_PARENT1_UNQ1: pkey_id c=_, R= TABLE ACCESS FULL 4*DTOW_TYPE c=2, R=3

Measurement Example SESSION_ID Oracle_PID Client_PID Elapsed: 00:00: Hand-tuned plan, with hints 16 ; CDATE PDATE TCDESC TPDESC Elapsed: 00:00:00.16 LIO PIO Logical Reads = 3012 Physical Reads = 0

Unfair Advantages Humans Enjoy CBO lacks insight into the freedom to change corner-case behavior: SQL constitutes a rigorous, unambiguous spec for what the CBO must deliver, functionally, regardless of cost, without the slightest risk of wrong-rows bugs in even the most obscure corner cases!

Unfair Advantages Humans Enjoy CBO lacks insight into the freedom to change corner-case behavior: Humans understand which corner cases we can safely ignore. Humans understand that even for corner cases we cannot ignore, the current corner-case behavior specified by the SQL may be wrong, and should be changed, if it is wrong, and if it prevents access to a fast execution plan.

Corner-Case Example test5 1 SELECT --This is unchanged by dynamic sampling!!! 2 C.PKey_ID CKey_ID, 3 C.Date_Col CDate, 4 G.PKey_ID GKey_ID 5 FROM DTow_Talk_Child C, 6 DTow_Talk_Generic G 7 WHERE C.PKey_ID=G.Generic01 8* AND C.PKey_ID= SELECT STATEMENT c=2170, R=1..2 NESTED LOOPS c=2170, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=3, R= INDEX UNIQUE SCAN DTOW_TALK_CHILD_UNQ1: pkey_id c=2, R=1...3 TABLE ACCESS FULL 2*DTOW_TALK_GENERIC c=2167, R=1

Corner-Case Example 9 ; CKEY_ID CDATE GKEY_ID JAN Elapsed: 00:00:01.26 LIO PIO Logical Reads = Physical Reads = 0

Corner-Case Example test8 1 SELECT 2 C.PKey_ID CKey_ID, 3 C.Date_Col CDate, 4 G.PKey_ID GKey_ID 5 FROM DTow_Talk_Child C, 6 DTow_Talk_Generic G 7 WHERE TO_CHAR(C.PKey_ID)=G.Generic01 8* AND C.PKey_ID= SELECT STATEMENT c=6, R=1..2 NESTED LOOPS c=6, R=1...3 TABLE ACCESS BY INDEX ROWID 1*DTOW_TALK_CHILD c=3, R= INDEX UNIQUE SCAN DTOW_TALK_CHILD_UNQ1: pkey_id c=2, R=1...3 TABLE ACCESS BY INDEX ROWID 2*DTOW_TALK_GENERIC c=3, R= INDEX RANGE SCAN DTOW_TALK_GENERIC_GENERIC01: GENERIC01 c=2, R=1

Corner-Case Example 9 ; CKEY_ID CDATE GKEY_ID JAN Elapsed: 00:00:00.15 LIO PIO Logical Reads = 9 Physical Reads = 0

Unfair Advantages Humans Enjoy CBO lacks insight into the freedom to change corner-case behavior: View-using queries are the most common example of queries with quirky corner-case behaviors (almost never anticipated by the developers) that trigger expensive execution plans.

Overview Introduction – the Nature of the Game The CBO versus the Human “Player” Choices Unavailable to the CBO Objections to Human Tuning, Addressed

Choices Unavailable to the CBO The CBO’s game: Tune fast. Tune at runtime, without executing SQL against application data. Take each SQL spec as gospel. Use only what can be deduced or assumed from dictionary statistics. Use the database as-is.

Choices Unavailable to the CBO Higher-level games for human tuning: Take as long as necessary to tune. Verify fixes! Learn what needs to be learned any way necessary. Consider altering corner-case behavior of the SQL. Use existing denormalizations. Educate end users to avoid unnecessary, hard problems (e.g., search on phone number, not last name.)

Choices Unavailable to the CBO Higher-level games for human tuning: Consider modifying the application: –Read fewer rows. –Read less frequently, or not at all. –Move load off-hours, or into batch. –Combine multiple statements into one. –Break one statement into multiple statements.

Choices Unavailable to the CBO Higher-level games for human tuning: Consider modifying the database: –Add or modify indexes. –Denormalize the database (rarely necessary!). –Add constraints that secure corner-case issues. –Alter the database design.

Overview Introduction – the Nature of the Game The CBO versus the Human “Player” Choices Unavailable to the CBO Objections to Human Tuning, Addressed

“The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.”

Objections to Human Tuning, Addressed “The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.” YES!

Objections to Human Tuning, Addressed “The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.” That’s about right!

Objections to Human Tuning, Addressed “The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.” Corrollary: It’s a waste of time to just tune SQL at random, or to tune all SQL!

Objections to Human Tuning, Addressed “The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.” However, that can still leave hundreds of badly tuned queries in a complex application suite!

Objections to Human Tuning, Addressed “The CBO’s assumptions and approximations are fine! It finds a great plan, or at least a good enough plan, 99% of the time.” If you find the right SQL to tune (method R or similar, runtime-based methods), you will find that most of that SQL has ready opportunities for improvement! This is not a paradox!

Objections to Human Tuning, Addressed “Most developers do not know enough to outsmart the CBO.” OK, if you are among those developers, learn more! –… Or hire someone who already knows how;-)

Objections to Human Tuning, Addressed “The CBO only fails when the database (or application) design is bad.” Even if this was true, so what?! Bad design happens! (Tune in the real world!) We (in this room, today) almost never have the chance to start at, and completely control, the design! Tuning slow SQL is a great way to uncover needed fixes to bad design!

Objections to Human Tuning, Addressed “Even if you can improve the query, today, tuning is a bad idea because hints will over- constrain the CBO in the future.” Less than half of SQL tuning even involves beating the CBO at its own game! –Add indexes, change the application, denormalize,… –These changes do not constrain the future CBO!

Objections to Human Tuning, Addressed “Even if you can improve the query, today, tuning is a bad idea because hints will over- constrain the CBO in the future.” Even when you beat the CBO at its own game, you don’t always need hints to do it! –E.g., convert subqueries to inline views. –E.g., convert view-using queries to queries of simple tables. –These changes do not constrain the future CBO!

Objections to Human Tuning, Addressed “Even if you can improve the query, today, tuning is a bad idea because hints will over- constrain the CBO in the future.” When you do need hints to beat the CBO at its own game, so be it! These are big improvements! –Take the “bird in the hand”! –Use a robust execution plan. –The SQL will probably change, anyway, long before your hint will be even marginally likely to get in the CBO’s way!

Questions?