Download presentation
Presentation is loading. Please wait.
Published byCecilia Osborne Modified over 6 years ago
1
Query Optimization for Object-Relational Database Systems
Navin Kabra Advisor: Professor David J. DeWitt
2
Query Optimization is…
Important Difficult
3
Problem Areas Difficult to implement a new optimizer
Difficult to extend/modify existing optimizer Difficult to debug optimizer bugs Optimizer doesn’t always work
4
Difficult times ahead Complex Queries Complex Data
Decision support, OLAP, Mining, Terabytes of data Complex Data User-defined types (UDTs), User-defined functions/methods (UDFs)
5
Road Map Introduction The Opt++ Architecture
Extensibility features of Opt++ Debugging Support Conclusions
6
OPT++: Basic Idea Code Independent of Query Algebra Well-Defined
Interface Code Dependent on Query Algebra
7
OPT++ Overview Code provided with OPT++ RUNTIME BINDING Code written
Search Strategy Abstract Classes RUNTIME BINDING Code written by Optimizer Implementor Derived Classes
8
Abstract Classes Operator class (logical algebra)
Algorithm class (physical algebra) Generator classes (search space)
9
An Example Query Select * from Emp, Dept where Emp.name = “Lee”
AND Emp.dno = Dept.dno
10
An Operator Tree
11
An Access Plan
12
Operator Tree & Access Plan
13
Tree Descriptors
14
Plan Descriptors
15
Operators and Algorithms
Search Strategy Operators Algorithm Select Join Index Scan Hash
16
Expand - Example
17
Expand - continued
18
Expand - continued
19
Going from a Tree to a Plan
20
Generators Select Join Index Scan Hash Join Search Strategy
Plan Generator Operators Algorithm Tree Generator Select HashJoin Gen Join Index Gen SelectPushdown Index Scan LeftDeep Gen Hash Join
21
Example: Merge Join
22
Example: Merge Join - continued
23
Enforcing Sorts
24
Enforcing Sorts
25
System-R style search strategy
26
Changing the Search Strategy
2PO Bottom Up SA II Transformative Plan Generator Operators Algorithm Tree Generator Select HashJoin Gen Join Index Gen SelectPushdown Index Scan LeftDeep Gen Hash Join
27
A Transformation
28
Transformation-based Search Strategies
Volcano-style Randomized Iterative Improvement Simulated Annealing Two-phase Optimization
29
Road Map Introduction The Opt++ Architecture
Extensibility features of Opt++ Debugging Support Conclusions
30
Optimizer Components Search Strategy Search Query Space Algebra 2PO SA
Bottom Up SA II Transformative Plan Generator Operators Algorithm Tree Generator Select HashJoin Gen Join Index Gen SelectPushdown Index Scan LeftDeep Gen Hash Join Search Space Query Algebra
31
Extending an Optimizer (Query Algebra)
Add Operator and Algorithm classes Add Generator classes No changes to search strategy required
32
Adding an Algorithm Search Strategy Search Query Space Algebra 2PO SA
Bottom Up SA II Transformative Plan Generator Operators Algorithm Tree Generator Adaptive HashJoin Gen Adaptive HashJoin Select Join Index Scan HashJoin Gen SelectPushdown Index Gen LeftDeep Gen Hash Join Search Space Query Algebra
33
Adding an Operator Search Strategy Search Query Space Algebra 2PO SA
Bottom Up SA II Transformative Plan Generator Operators Algorithm Tree Generator AggrGen HashAggr Gen Select Hash Aggr Join HashJoin Gen Index Scan Index Gen SelectPushdown LeftDeep Gen Hash Join Search Space Query Algebra
34
Extending an Optimizer (Search Strategy)
Add new SearchStrategy class Possibly add new Generator classes No changes to Query Algebra component
35
Adding a Tree Generator
Search Strategy Search Strategy 2PO Bottom Up SA II Transformative Plan Generator Operators Algorithm Tree Generator BushyJoin Gen Select SelectPushdown HashJoin Gen Join Index Gen LeftDeep Gen Index Scan Hash Join Search Space Query Algebra
36
Extending an Optimizer (Search Space)
Add or remove appropriate Generator classes No changes to Search Strategy No changes to Query Algebra
37
Adding a Search Strategy
2PO Search Strategy SA Bottom Up A-Star II Transformative Plan Generator Operators Algorithm Tree Generator Select HashJoin Gen Join Index Gen SelectPushdown Index Scan LeftDeep Gen Hash Join Search Space Query Algebra
38
Road Map Introduction The Opt++ Architecture
Extensibility features of Opt++ Debugging Support Conclusions
39
Debugging Support Lots of time spent debugging the optimizer
Non-optimal plans produced due to Bugs in enumeration logic Bugs in cost model
40
Debugging Support - continued
Optimizer Implementor indicates “expected” plan Optimizer indicates why “expected” plan was not produced Sets automatic breakpoints (inside a debugger) at appropriate location Only for Bottom Up Search Strategy Partially useful for other search strategies
41
Bug in Cost Model Expected Plan Generated Plan
42
Bug in Plan Enumeration
Expected Plan Generated Plan Generated Tree
43
Bug in Tree Enumeration
Expected Plan Generated Tree
44
Partial Plan Specification
Optimizer Implementor does not want to specify full plan Allow specification of a “plan fragment” A plan tree with incomplete information (and “Don’t Cares”)
45
Partial Plan - Join Order
46
Partial Plan - Index Select
47
Partial Plan - General
48
Partial Plan - Complex
49
Using Partial Plans Allow Breakpoints using Partial Plans
Force Plans using Partial Plans (discussed next)
50
Force Plans Using Partial Plans
Over-ride the Optimizer Useful because During cost model validation Debugging and tuning the system End user wants to force a plan Optimizer tries to produce a plan that matches the specification
51
Force Plans - DML Select * from Emp, Dept where Emp.name = “Lee”
AND Dept.dno = Emp.dno hint “{algorithm hashjoin leftinput {algorithm indexscan}}”
52
Conclusions The Opt++ architecture simplifies
implementation maintenance experimentation Techniques for debugging an optimizer very useful more work needed
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.