HAMILTON_DB

A small relational database written in Rust. Row-based, fixed-size pages on disk, Postgres-compatible SQL. Built to learn how databases work from the inside.

Fig. 1 — One page of a table heapRows inserted: 6 / 6
Fixed-size pagesEvery table is stored as pages of the same size on disk.
Slots point to rowsThe slot array at the front records where each row lives.
Whole rowsEach tuple is stored whole in its slot. That's what row-based means.

Built from the page up.

Each layer is its own crate, from SQL at the top down to the bytes on disk.

Types:INTBIGINTBOOLVARCHAR(n)

Take it
for a spin.

Clone the repo, build the workspace and open the interactive SQL shell. Then race it against a local Postgres loaded with the same data.

$ cargo build --workspace
$ cargo test --workspace
$ cargo run -p hamilton-cli
$ cargo run --release -p bench -- --pg postgres://postgres@127.0.0.1:5432