Chapter 1
Chapter 1
Chapter 1
Example:-
SQL query
Select emp_name from Employee where salary>10000
Translated Relational Algebra
• σsalary>10000 (πsalary (Employee)) OR
• πsalary (σsalary>10000 (Employee))
(S))
If the join condition C contains additional
attributes not in L, these must be added to the
projection list, and a final p operation is needed.
Prepared by Elisaye B. @WSU-DTC 38
Using Heuristics in Query Optimization(12)
8. Commutativity of set operations: The set operations
υ and ∩ are commutative but “–” is not.
9. Associativity of , x, υ, and ∩ : These four
operations are individually associative; that is, if q
stands for any one of these four operations
(throughout the expression), we have
(Rq S)q T=Rq (Sq T)
10.Commuting s with set operations: The s operation
commutes with υ , ∩ , and –. If q stands for any one
of these three operations, we have
sc ( R q S ) = (sc (R)) q (sc (S))
Prepared by Elisaye B. @WSU-DTC 39
Using Selectivity and Cost Estimates in
Query Optimization (1)
Cost-based query optimization:
• Estimate and compare the costs of executing a
query using different execution strategies and
choose the strategy with the lowest cost estimate.
Issues
Cost function
Number of execution strategies to be considered