A columnar/analytical query engine written from scratch. The goal is to learn and implement the big pieces of what make up a modern query engine, not to build the latest algorithms for micro-optimizations in query execution. Query performance benchmarks are run against Clickbench and TPC-H.
The key pieces are:
- Reads: Skip, decompress, and decode only the bytes the query needs. Parquet files are the current target.
- Execution: Keep hardware saturated, efficiently pipeline/parallelize work, auto-vectorization, push vs. pull model, etc.
- Optimizer: Build a query optimizer. This is what turns a query into the plan that the execution stage runs.
- Perform fine-grained query predicate filtering on encoded data pages. For example, on a dictionary-encoded data page, you can evaluate a filter against the dictionary once rather than materializing the entire dictionary and evaluating per-row. Modern query engines generally have some level of support for this, though often not for all applicable codecs (e.g. ALP, RLE, and likely many more).
- I'm building a custom Parquet file reader (https://github.com/lgingerich/parkay). Besides simply making a faster reader than arrow-rs/parquet, by owning this piece also, potentially there is some functionality I can build which is a novel optimization over standard Parquet<>Query Engine integrations.
- Query optimizers traditionally mix two related but different jobs: algebraic normalization (deterministic rewrites governed by SQL semantics, like subquery decorrelation and projection pruning) and cost-based planning (heuristic choices like join order and physical operators).
- Most query engines implement algebraic normalization as dozens of tangled, imperative AST passes—a major source of subtle correctness bugs around
NULLs, duplicates, errors, and stale schemas. - https://github.com/lgingerich/sqlemma is my very early attempt of pulling that algebraic layer out into a clean, operator-centric set of machine-checked laws in Lean 4 that query engines can eventually plug into and use to replace (or verify) the algebraic normalization step of a query optimizer.
- Successfully doing this would greatly simplify the amount of code that a query optimizer must write, and more importantly, eliminate entire classes of bugs on invalid SQL results.
- Most query engines implement algebraic normalization as dozens of tangled, imperative AST passes—a major source of subtle correctness bugs around
Misc Research:
- https://arxiv.org/abs/2307.15255
- https://duckdb.org/library/robust-predicate-transfer-vldb/
- https://arxiv.org/abs/2506.10092
- https://arxiv.org/abs/1610.09166
scripts/perf runs everything: hardware limits, query timings with allocation counts, CPU profiles, and heap profiles, with DataFusion as a reference engine. See docs/BENCHMARKING.md for what each layer is for and when to use it.
MIT. See LICENSE for the full text.