← back

SQL Query Engine

2024 · Rust · Database Internals

Rust SQL B-tree Query Planner

A relational query engine that parses SQL, builds a logical plan, applies cost-based optimizations, and executes via a Volcano-model iterator tree. Supports B-tree indexes, joins, aggregations, and transactions.

Architecture

Design Decisions

What I Learned

The buffer pool manager is the most consequential component — a bug there corrupts data silently. Rust's ownership model caught several use-after-free issues at compile time that would have been subtle runtime bugs in C++.

Cost-based optimization is hard to get right without good statistics. Cardinality estimation errors compound through join chains, leading to dramatically wrong plan choices.