15. The method of claim 1, further comprising steps of executing the optimized query upon the relational database.
1. A method of optimizing an SQL query that includes at least one subquery, wherein said query is executable by a computer to retrieve data from a relational database stored in electronic storage coupled to the computer, the method comprising the steps of: representing the query in storage as a query box representation comprising a hierarchical assembly of multiple data structures corresponding to the at least one subquery, each data structure being referred to as a "box"; examining each box individually, the box under examination being referred to as the current box, to determine whether the current box has any correlated descendant box that receives correlation bindings from an original source comprising the current box or an ancestor box of the current box; and determining whether the correlated descendant box can be decorrelated, and if so creating an optimized query by applying a magic decorrelation process to create a different source for the correlation bindings and substitute the different source for the original source, said different source being hierarchically inferior to the current box.