HEUR
HEUR
Optimization
1/9
Heuristic-Based Query Optimization
• Outline of heuristic algebraic optimization algorithm
1. Break up SELECT operations with conjunctive conditions
into a cascade of SELECT operations
2. Using the commutativity of SELECT with other operations,
move each SELECT operation as far down the query tree as
is permitted by the attributes involved in the select
condition
3. Using commutativity and associativity of binary
operations,
rearrange the leaf nodes of the tree
4. Combine a CARTESIAN PRODUCT operation
with a
subsequent SELECT operation in the tree into a JOIN
operation, if the condition represents a join condition
5. Using the cascading of PROJECT and the commuting
of
PROJECT with other operations, break down and
move
lists of projection attributes down the tree as far as possible
by creating new PROJECT operations as needed
6. Identify sub-trees that represent groups of operations that
can be executed by a single algorithm 2/9
Heuristic-Based Query Optimization:
Example
• Query
"Find the last names of employees born after
1957 who work on a project named ‘Aquarius’."
• SQL
SELECT LNAME
FROM EMPLOYEE, WORKS_ON, PROJECT
WHERE PNAME=‘Aquarius’ AND PNUMBER=PNO AND
ESSN=SSN AND BDATE.‘1957-12-31’;
3/9