Documentation / 0.1.0-beta.16
NusaDB documentation
Reference for NusaDB 0.1.0-beta.16, a single-node relational database written in Rust: installing and running it, the SQL it accepts, transactions, clients and limits.
Where to start
| To | Read |
|---|---|
| Decide whether NusaDB fits a project | Limits and capacity, then the wire protocol below |
| Understand how rows are stored, logged and recovered | How it works |
| Install and run a first query | Getting started |
| Connect an application | Official clients and connection settings |
| Look up a statement, type or function | SQL statement index |
| Handle conflicts and retries | Transactions |
| Configure and deploy a server | Server flags, systemd, backup |
| Upgrade an existing data directory | Upgrades |
| Interpret an error code | Error codes |
Architecture
Requests arrive over the Nusa wire protocol and pass through a parser, an analyzer that resolves names and checks types, a planner that picks an execution strategy from collected statistics, and a vectorized executor that processes rows in batches.
The storage engine is a clustered B-link/B+tree. Rows live in the leaves, keyed by a row id the engine assigns, so a primary-key lookup ends at the leaf with no second lookup in a separate heap. Each row version records the transaction that created it and the one that removed it. Readers use these stamps to work from a snapshot without blocking writers, and a background worker removes versions that no snapshot can still see.
The write-ahead log provides durability. A commit is acknowledged after its record is durable; each record carries a CRC32 and is lz4-compressed. A checkpoint writes the pages changed since the previous one into a new page segment, publishes an image naming every page, and truncates the log. At start-up the engine opens that image, loads pages from it as they are used, and replays only the log written after it.
How it works, with diagrams of the page, the log frame and a checkpoint
| Layer | Responsibility |
|---|---|
| Client | nusadb-cli and the official drivers. |
| Protocol | Framing, TLS, SCRAM-SHA-256 authentication, extended query flow. |
| SQL engine | Parser, analyzer, planner and cost model, vectorized executor. |
| Transactions | Multi-version rows, no-wait locking, isolation levels, rollback. |
| Storage | Clustered B-link/B+tree, secondary indexes, version store, catalog, page cache with eviction and spill. |
| Log | Append-only write-ahead log with per-record checksums and compression, incremental checkpoints over immutable page segments, optional archive for point-in-time recovery. |
Wire protocol
NusaDB has its own wire protocol. Clients written for other database engines cannot connect: the server does not answer a handshake it does not recognise, so the client sees a connection that never responds.
The SQL dialect is independent of the wire format, and queries written for other engines
usually run unchanged. To connect, use nusadb-cli, one of the
official clients, or a client written against the
protocol specification.
Conventions
- Shell commands assume the release binaries are on your path, or are run from
./target/release/. - SQL examples are written for
nusadb-cliand end with a semicolon. - Output shown under an example was produced by this release.
- Features are listed only when they are implemented and tested. Missing features are listed on the limits page.
Reporting problems
Report bugs and ask questions in the issue tracker. Include the release or image digest, the statements that reproduce the behaviour, and the result you expected. For problems with data size or restart time, include the size of the data directory, since restart time depends on it more than on the row count (restart time).