Cost-based Query Optimiser
Approximate algorithm for cost-based optimisation:
translate SQL query to RAexp
for enough transformations RA' of RAexp {
while (more choices for RelOps) {
Plan = {}; i = 0; cost = 0
for each node e of RA' {
ROp = select RelOp method for e
Plan = Plan ∪ ROp
cost += Cost(ROp)
}
if (cost < MinCost)
{ MinCost = cost; BestPlan = Plan }
}
}
|
Heuristics: push selections down, consider only left-deep join trees.
|