Posts

Showing posts from November, 2009

Heuristic Optimization of SQL Queries

Image
In general, relational algebra expressions and query trees could be equivalent; that is, they may correspond to the same query. But, the performance or cost of query may vary depending on the query technique that we apply. An optimization technique helps reduce the query execution time as well as the cost by re-formatting the query. We applied heuristic optimization in our queries and could reduce the execution time to a greater extent and thus reduced the cost quite a bit. Figure 1: Initial Query If we write this query in SQL we get: Select Name from E, J, P where E.EID=J.EID and PCode=Code and P.Name='GreenLife' and E.BDate>'31-12-1967' Which is basically the cross product of E, J and P Outline of a Heuristic Algebraic Optimization Algorithm: Break up any select operations with conjunctive conditions into a cascade of select operations. Move each select operation as far down the query tree as is permitted by the attributes involved in the select condition. Rearrang...