SQL Engine - Query Rewrite
1 - About
The query rewrite is a feature of the RDBMS Modeling - (Materialized|Aggregate) (View|Table) capabilities.
The real power behind aggregate table and query rewrite is that their use is transparent to the user. In the same way that a user doesn’t have to know about the indexes on a table to use them, then likewise, a user doesn’t have to know about the presence, structure and content of the materialized view. Query Rewrite enables this transparent use of aggregate table and is a query optimisation mechanism whereby the original query SQL, which is written against the base tables, is automatically rewritten by the optimiser to access the appropriate materialized views.
2 - Articles Related
3 - About
Normally, when QUERY REWRITE ENABLED is set to FALSE, the database will take your SQL as is, parse it, and optimize it. With query rewrites enabled, The database will insert an extra step into this process (For Oracle, the query transformer do the job). After parsing, it will attempt to rewrite the query to access some RDBMS Modeling - (Materialized|Aggregate) (View|Table), instead of the actual table that it references. If it can perform a query rewrite, the rewritten query (or queries) is parsed and then optimized along with the original query. The query plan with the lowest cost from this set is chosen for execution. If it cannot rewrite the query, the original parsed query is optimized and executed as normal.