Parametric Query Optimization for Linear and Piecewise Linear Cost Functions
Arvind Hulgeri
- S. Sudarshan
Parametric Query Optimization for Linear and Piecewise Linear Cost - - PowerPoint PPT Presentation
Parametric Query Optimization for Linear and Piecewise Linear Cost Functions Arvind Hulgeri S. Sudarshan Dept of Computer Science and Engg. Indian Institute of Technology Bombay Parametric query: An example Select * From A, B Where A.x =
VLDB 2002 2
E.g. Cost function f = a1.s1 + a2.s2 + a3
Where, s1 = selectivity of predicate “A.z < ?”
(using merge-join assuming relations are sorted on
VLDB 2002 3
Conventional optimization
Assumes complete knowledge of all cost parameters
E.g. selectivity and resource availability
Generates a single optimal plan for a given query
Parametric query optimization (PQO)
Generates multiple candidate plans, each optimal for
POSP: Parametrically optimal set of plans
Picks appropriate plan at run time
VLDB 2002 4
VLDB 2002 5
linear, piecewise linear and non-linear
Recursive decomposition algorithm Cost polytope algorithm
Extend a conventional query optimizer
VLDB 2002 6
VLDB 2002 7
VLDB 2002 8
VLDB 2002 9
Partition the polytope into two polytopes Continue recursively
VLDB 2002 10
VLDB 2002 11
N parameter dimensions + 1 cost dimension
A lower convex polytope that represents the
VLDB 2002 12
VLDB 2002 13
Start with a initial cost polytope Put vertices of the parameter space polytope
Repeat till the queue is empty
Remove and optimize the first vertex in the queue Intersect the cost hyperplane with the cost polytope Project new vertices of the cost polytope onto
VLDB 2002 14
VLDB 2002 15
VLDB 2002 16
VLDB 2002 17
VLDB 2002 18
VLDB 2002 19
VLDB 2002 20
VLDB 2002 21
VLDB 2002 22
VLDB 2002 23
Partition the parameter space into convex polytopes
Within each partition the cost function is linear in the
But pre-partitioning the space to make all cost
VLDB 2002 24
Extend a conventional query optimizer
Extensions are intrusive to the query optimizer Partition space only when necessary (“on demand”) Extend plan cost:
Cost Cost function
Extend comparison of alternative operators or plans
Pick min cost plan MinMergeCostFunctions
Extensions work for arbitrary number of
VLDB 2002 25
VLDB 2002 26
VLDB 2002 27
Replace cost by cost function Use AddCostFunction instead of simple cost
Use MinMergeCostFunction instead of simple
VLDB 2002 28
VLDB 2002 29
Simple and minimally intrusive Works for arbitrary number of parameters
Intrusive Works for arbitrary number of parameters Very general since nonlinear and discontinuous