This paper describes the various techniques that are used to create a query compiler that converts high-level (declarative) logic into low-level optimized (imperative) logic. The paper argues that conventional methods for compiling queries i.e. template expanders have the following weaknesses -
- Everything is compiled in a single big stage which makes the logic complex and difficult to modify/expand
- Combinations cause an explosion of possible cases because each combination has to be checked with all others making it O(n^2)
The paper argues that having multiple stages that gradually lower the query through multiple DSLs each performing a specific type of transformation is a scalable and effective approach. The paper defines the two types of transformations.
- Optimizations - when the transformation occurs at the same level i.e. the construct in a DSL is expressed differently but within the same DSL.