The SQL compiler includes a rewrite query stage which transforms SQL statements into forms that can be optimized more easily, and as a result, can improve the access path chosen. Rewriting queries is particularly important for queries which are very complex, including those queries with many subqueries or many joins. Query generator tools often create these types of very complex queries.
You can influence the number of query rewrite rules that are applied to an SQL statement by changing the optimization class (see Adjusting the Optimization Class).
You can see some of the results of the query rewrite through the use of the Explain facility or Visual Explain.
There are three major categories of rewriting that the SQL compiler may perform: