Paper · Query Processing

Efficiently Compiling Efficient Query Plans for Modern Hardware

T. Neumann · VLDB · 2011

Compiling queries to machine code, the alternative to vectorisation.

Summary

The iterator model incurs a virtual function call for every tuple at every operator, and moves data through operators in a way that works against CPU registers and caches. As data moved into main memory, this overhead became a major cost. The paper, from the HyPer system, proposes generating machine code for each query instead.

Instead of pulling tuples, the generated code pushes them through pipelines. Operators are fused together until a pipeline breaker, such as building a hash table, is reached, so a tuple can stay in CPU registers for the whole pipeline. HyPer generates LLVM intermediate code for these loops and compiles it at runtime.

Data-centric code generation is now used in several commercial and research systems. Together with vectorisation, it frames the main design choice for modern query engines, and later work compares and combines the two approaches.

Key ideas

  • Compile each query to machine code instead of interpreting a plan.
  • Push-based, data-centric execution rather than pull-based iterators.
  • Fuse operators into pipelines so tuples stay in CPU registers.
  • Use LLVM to generate and compile code quickly at runtime.

More Query Processing papers