BlazeDB: Custom SQL Engine with Query Optimization
BlazeDB is a SQL engine written from scratch in Java. It parses SQL queries, translates them into relational algebra, optimises the resulting plan and executes it: the same pipeline at the heart of production databases, built end to end.
Query pipeline
01
Parse
JSqlParser turns the SQL text into a syntax tree
02
Translate
The tree is mapped to relational algebra operators
03
Optimise
Selections and projections are pushed down; joins arranged as a left-deep tree
04
Execute
Operators evaluate the plan against the schema and data
What it supports
- ▸SELECT with filtering and projection
- ▸JOINs across multiple tables
- ▸GROUP BY with aggregation functions
- ▸Schema-aware evaluation, so columns are resolved against the right tables
Why the optimiser matters
The same query can be executed in many ways, and the difference can be orders of magnitude. Pushing selections down filters out rows as early as possible, and pushing projections down drops unneeded columns, so later operators, especially joins, process far less data. Arranging joins as a left-deep tree gives a predictable plan in which each join's output feeds directly into the next.