Programming at Light Speed: Building the Gravity Query Engine
Summary
This article details Gravity, the query engine in pgrust v0.4-beta, and how it achieves high-speed performance by starting from hardware limits and building upward. It covers the multi-stage compiler pipeline, Lisp IR, and several key optimizations (inlining, late materialization, and run collapse) that bring runtime performance close to handcrafted Rust code. Benchmarks show Gravity delivering significant speedups over traditional analytical databases while supporting Postgres SQL dialect and type system.