Skip to content

sitareashish/mini-sql-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mini-sql-engine

A SQL execution engine written from scratch in C++. B+ Tree over a buffer pool, volcano-model iterators, and (v2, in progress) ARIES WAL + MVCC.

v1: done (Jan–Feb 2026). v2: in progress (Jul 2026).

v1

  • Buffer pool with LRU eviction over fixed-size pages
  • B+ Tree indexes on top of the buffer pool
  • Volcano iterators — Scan / Filter / Project / Join, each with Next()
  • Slab allocator for per-query scratch, RAII scoped
  • NL-to-SQL layer via LLM function calling against a fixed schema
  • REPL: mini-sql> SELECT * FROM users WHERE age > 30;

v2 (in progress)

  • ARIES-style WAL, STEAL + NO-FORCE, group-commit fsync
  • Crash recovery: REDO forward from last checkpoint, UNDO backward for uncommitted txns
  • MVCC snapshot isolation with per-txn timestamps and old-version GC
  • 32-way reader benchmarks, no blocking on writers

v2 targets

what target
single-thread writes 100K+/sec
recovery on 1 GB WAL < 3 s
concurrent readers 32-way, non-blocking

Build

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/mini_sql
./build/mini_sql_bench
./build/mini_sql_test

Session

mini-sql> CREATE TABLE users (id INT PRIMARY KEY, name TEXT, age INT);
mini-sql> INSERT INTO users VALUES (1, 'Ada', 36), (2, 'Bob', 42);
mini-sql> SELECT name FROM users WHERE age > 30;
Ada
Bob
mini-sql> EXPLAIN SELECT name FROM users WHERE id = 1;
Project(name)
  IndexScan(users.id_index, id=1)

Layout

include/mini_sql/
  storage/       # buffer pool, B+ Tree, pages
  execution/     # volcano iterators
  parser/        # SQL parser
  recovery/      # v2 — WAL + ARIES
  mvcc/          # v2 — snapshot isolation
  llm/           # NL-to-SQL
src/
tests/
benchmarks/
docs/

References

  • Mohan et al., "ARIES" (TODS 1992)
  • Graefe, "Volcano — An Extensible and Parallel Query Evaluation System"
  • Hellerstein, Stonebraker, Hamilton, Architecture of a Database System

License

MIT

About

A from-scratch C++ SQL execution engine with buffer-pooled B+ Tree indexes, volcano-model iterators, ARIES WAL, and MVCC snapshot isolation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors