Relational SQL on one machine, from the wire protocol down to the 8 KiB page.
One server binary, written in Rust. Rows live in the leaves of a clustered B+tree,
COMMIT returns once a checksummed redo log is on disk, and drivers in eight
languages speak its own wire protocol.
$ docker run -d --name nusadb -p 5678:5678 \
-v nusadb-data:/var/lib/nusadb \
-e NUSADB_USER=app \
-e NUSADB_PASSWORD=change-me \
nusadb/nusadb:0.1.0-beta.16
nusadb-cli sessions, SERIALIZABLE
| session 1 | session 2 | |
|---|---|---|
| begin | nusa> BEGIN ...> ISOLATION LEVEL SERIALIZABLE; BEGIN |
nusa> BEGIN ...> ISOLATION LEVEL SERIALIZABLE; BEGIN |
| read | nusa> SELECT count(*) FROM oncall ...> WHERE on_shift; count ----- 2 SELECT 1 |
nusa> SELECT count(*) FROM oncall ...> WHERE on_shift; count ----- 2 SELECT 1 |
| write | nusa> UPDATE oncall SET on_shift = false ...> WHERE doctor = 'ana'; UPDATE 1 |
nusa> UPDATE oncall SET on_shift = false ...> WHERE doctor = 'budi'; UPDATE 1 |
| commit | nusa> COMMIT; COMMIT |
nusa> COMMIT; ERROR 40001: serialization conflict; transaction TxnId(7) must retry |
COMMIT is refused, so one stays on call. In each row session 1 ran first.
Output unedited apart from the connection banner. Retrying a 40001
One server, one disk, one SQL database you can reason about
For applications on a single host that want ordinary relational guarantees from it. It is not a cluster, so the second list matters as much as the first.
Fits today
- An application database on one host, with
SERIALIZABLEavailable per transaction when a race would be expensive. - Data larger than memory. Table and index pages are cached, evicted and spilled under
--max-resident-bytes. - Reporting next to transactions: window functions, recursive CTEs, grouping sets, and sorts, joins and aggregates that spill to disk instead of failing.
- Search without another service: full-text in the
simple,englishandindonesianconfigurations, andVECTOR(n)with an HNSW index. - Operators who want encryption at rest, scheduled backups and point-in-time restore from flags on the server binary.
Does not fit yet
- Failover without a person. There is no clustering. A read-only standby follows the primary and is promoted by restarting it without
--standby-from. - A standby that must trail by seconds. Log segments reach the archive when the primary checkpoints, so the standby lags by that cadence.
- Tools that speak another database's protocol. NusaDB has its own; use one of the eight drivers or
nusadb-cli. - Vector indexes larger than RAM. HNSW graphs are held in memory whatever the page-cache bound.
- Named time zones and locale collations.
SET TIME ZONEtakes UTC or a fixed offset, and text compares by bytes.
A commit is durable at the fsync. A checkpoint folds the log away.
Changed pages stay in the page cache and reach disk only through a checkpoint, which writes just those pages to a new immutable segment. Watch two transactions go through.
The row is in the leaf.
Tables are clustered B-link trees keyed by a row id the engine assigns, so a lookup ends at the leaf that holds the row, with no second hop into a separate heap. A reader that arrives during a split follows the right link instead of starting over.
Each log record carries its position, its length and a CRC over both.
The log is the durable copy of every change since the last checkpoint. Because the CRC32 covers the 16-byte header as well as the body, a zeroed sector or a corrupted length is caught, and a torn record at the end of the file ends the durable prefix cleanly.
--checkpoint-threshold-bytes)--checkpoint-interval)--checkpoint-max-pause)What kill -9 leaves behind
This session ran on the same server as the examples above. A checkpoint folds a
40 MB log into one full segment and truncates the log. An update of 100 rows adds a
32 KiB incremental segment at the next checkpoint. A row committed after the last checkpoint
exists only in a 224-byte log when the server is killed with SIGKILL, and it is
there after the restart.
Listings trimmed to size and name, and the shell's --host flag left out. Id 8 went to a transaction that never committed; identity values are not handed back on rollback. Other ways to keep a copy: scheduled hard-link backups, a log archive with point-in-time restore, and a read-only standby that follows the archive.
$ cd data && ls -l base/nusadb -rw-r--r-- 40529022 btree.wal -rw-r--r-- 45 btree.wal.format -rw-r--r-- 0 btree.wal.lock -rw-r--r-- 5 engine $ nusadb-cli -c "CHECKPOINT;" CHECKPOINT $ ls -l base/nusadb base/nusadb/btree.wal.pages -rw-r--r-- 0 btree.wal -rw-r--r-- 252931 btree.wal.ckpt -rw-r--r-- 45 btree.wal.format -rw-r--r-- 0 btree.wal.lock drwxr-xr-x btree.wal.pages -rw-r--r-- 5 engine -rw-r--r-- 100818944 00000000000000620069-18e3035d61f09521-full.seg $ nusadb-cli -c "UPDATE invoices SET amount = amount + 1 WHERE id <= 100; CHECKPOINT;" UPDATE 100 CHECKPOINT $ ls -l base/nusadb/btree.wal.pages -rw-r--r-- 100818944 00000000000000620069-18e3035d61f09521-full.seg -rw-r--r-- 32768 00000000000000620174-18e303603e38c911.seg # ... more statements from the examples above ... $ nusadb-cli -c "CHECKPOINT;" CHECKPOINT $ nusadb-cli -c "INSERT INTO orders (region, total, placed) VALUES ('south', 12.50, '2026-10-29');" INSERT 1 $ ls -l base/nusadb/btree.wal -rw-r--r-- 224 btree.wal $ pkill -9 nusadb-server $ nusadb-server --listen 127.0.0.1:47391 --data-dir . & $ nusadb-cli -c "SELECT id, region, total FROM orders WHERE id >= 6;" id | region | total ---+--------+------ 6 | south | 42.00 7 | south | 9.99 9 | south | 12.50 SELECT 3
Seven layers, one dependency direction
The storage side never imports the SQL side. They meet at one Rust trait, so each half can
be tested on its own. Storage code is also exercised against simulated disks that tear
writes, fail fsync and lose power, replayable from a single seed.
Client
nusadb-cliwith aligned, expanded, CSV and JSON output, drivers for Rust, Java, Node.js, Python, Go, Ruby, PHP and .NET, and a C API.Protocol
Length-prefixed frames on one port. TLS 1.3 through rustls, mutual TLS with
--tls-client-ca, SCRAM-SHA-256, extended query with named statements and portals,COPYin text and binary, notices.SQL engine
Parser, analyzer, a cost-based planner that reads histograms and most-common values, and a vectorized executor working on 1,024-row batches with AVX2 kernels and a portable fallback.
Transactions
Snapshots from version stamps, no-wait row locks, serializable snapshot isolation tracked per row, savepoints, two-phase commit, deferrable constraints.
Storage
Clustered B-link tables, B+tree indexes in pages too, a page cache with clock eviction and spill, HNSW graphs for vectors, and a background purge of dead versions.
Log
Redo records with CRC32 and lz4, optionally sealed, a commit that returns after fsync, incremental checkpoints over immutable segments, and an optional archive for point-in-time restore.
Files
One directory per database under
base/, a cluster catalog underglobal/, and a lock file that keeps a second server off the same directory.
Everything is a flag on nusadb-server
There is no configuration file and no second daemon. These are the flags most deployments
touch, with their defaults from --help. The full list of 44 is in
configuration.
| Flag | Default | What it does |
|---|---|---|
| Memory | ||
| --mem-budget | 0 (detect) | Total budget; on Linux, the smaller of host RAM and the cgroup limit. Work memory, the page-cache bound and spill to <data-dir>/tmp follow from it. |
| --max-resident-bytes | derived | Page-cache bound per database. Clean pages are evicted, changed pages spill. |
| --work-mem | derived | Per-stage budget for sorts, hash joins, aggregates and windows before they spill. |
| Security | ||
| --auth-user USER:PW | none | Turns on SCRAM-SHA-256 for every connection. Without it the server trusts all clients and logs a warning. |
| --tls-cert, --tls-key | none | TLS 1.3 on the same port. Add --tls-client-ca to require client certificates. |
| --encryption-key-file | none | Seals the log, checkpoint image, segments, spill files, archive and backups with AES-256-GCM-SIV under a per-database data key. |
| Copies | ||
| --backup-dir | none | Hard-link backups every --backup-interval (86400 s), keeping --backup-keep (7). |
| --wal-archive-dir | none | Archives each checkpoint's log segment and image, for --restore-to-time or --restore-to-lsn. |
| --standby-from | none | Runs a read-only standby that follows a primary's archive. |
| Connections | ||
| --max-connections | 25 | Extra connections queue; --reject-excess-connections refuses them with 53300 instead. |
| --statement-timeout | 0 (off) | Cancels a statement after this many seconds with 57014. |
| --metrics-listen | none | Serves metrics in Prometheus text format on a separate address. |
Numbers, with the machine and the build they came from
Single-machine measurements on a laptop, not a tuned benchmark. Each was taken on an earlier 0.1.0 build named next to it, and none has been repeated on beta.16. They show orders of magnitude, not a ceiling.
| Result | What was measured |
|---|---|
| 0.1 ms | Median and 95th-percentile primary-key lookup, 1,000 lookups on a 100,000-row table, Python driver over TCP loopback, one connection.2026-09-26 · build 9793cb5 |
| 2.7 ms | SELECT count(*) over the same 100,000 rows, as a non-superuser role.2026-09-26 · build 9793cb5 |
| 713 ms | UPDATE … SET v = v + 1 on all 100,000 rows in one statement.2026-09-26 · build 9793cb5 |
| 0.25–0.28 ms | Range filter with ORDER BY k LIMIT 20 on 500,000 rows after ANALYZE; the plan reads the index in order and stops at the limit. Best of five after a warm-up.2026-09-27 · build c37b16f |
| 0.27–0.29 s | Server start to first query answered, 600,000 rows of 400 random bytes with a primary key, 296 MB checkpoint image.2026-09-27 · build 259200c |
| 64 MB | Resident memory during a full scan of those 600,000 rows with the page cache bounded at 64 MB (engine probe, 140 ms). Opening the engine took 4 ms.2026-09-27 · build 259200c |
| 33/33, 26/26 | Driver checks passed by the published Python 0.1.2 and Rust 0.1.2 packages against a release server.2026-10-14 · build 0437b3e |
Cost of encryption at rest
200,000 rows of 200 bytes, transactions of 1,000 rows, median of three runs. Each pair of bars has its own scale.
- unencrypted
- encrypted
| Operation | Unencrypted | Encrypted |
|---|---|---|
| Bulk insert | 1.42 s | 1.51 s |
| Checkpoint | 41 ms | 51 ms |
| Reopen | 3.5 ms | 3.6 ms |
| Scan, cold cache | 24 ms | 42 ms |
A sealed page takes 8,220 bytes instead of 8,192, and a log record 28 bytes more. Pages already in the cache cost nothing extra.
Hardware: an Apple Silicon MacBook Pro, macOS (Darwin 25.5), local disk, no container, release builds. The encryption figures are from the engine's own architecture notes (2026-10-14, Apple M-series laptop).
Measurements over the wire include the round trip through the Python driver on loopback. The engine probe runs in process.
Eight languages, no native dependencies
Every driver speaks the protocol directly and binds parameters as $1,
$2. Typed columns come back as the language's own types: integers, decimals,
datetimes, parsed JSON.
import nusadb conn = nusadb.connect(host="127.0.0.1", port=5678, user="app", password="change-me", database="nusadb") cur = conn.cursor() cur.execute("SELECT id, region FROM orders WHERE total > $1", [100]) for row in cur: print(row) conn.close()
use nusadb::Connection; let mut conn = Connection::connect("nusadb://app:change-me@127.0.0.1:5678/nusadb")?; let rows = conn.query_params( "SELECT id, region FROM orders WHERE region = $1", &[&"east"])?;
const { connect } = require('nusadb'); const conn = await connect({ host: '127.0.0.1', port: 5678, user: 'app', password: 'change-me', database: 'nusadb' }); const res = await conn.query('SELECT id, region FROM orders WHERE region = $1', ['east']); console.log(res.rows); await conn.close();
import ( "database/sql" _ "github.com/nusadb/go" ) db, err := sql.Open("nusadb", "nusadb://app:change-me@127.0.0.1:5678/nusadb") var region string err = db.QueryRow("SELECT region FROM orders WHERE id = $1", 1).Scan(®ion)
import java.sql.*; String url = "jdbc:nusadb://app:change-me@127.0.0.1:5678/nusadb"; try (Connection conn = DriverManager.getConnection(url); PreparedStatement ps = conn.prepareStatement("SELECT region FROM orders WHERE id = $1")) { ps.setLong(1, 1); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) System.out.println(rs.getString("region")); } }
require 'nusadb' conn = NusaDB.connect(host: '127.0.0.1', port: 5678, user: 'app', password: 'change-me', database: 'nusadb') result = conn.query('SELECT id, region FROM orders WHERE region = $1', ['east']) conn.close
use NusaDB\Connection; $conn = new Connection('nusadb:host=127.0.0.1;port=5678;dbname=nusadb', 'app', 'change-me'); $sel = $conn->prepare('SELECT id, region FROM orders WHERE region = $1'); $sel->execute(['east']); foreach ($sel->fetchAll() as $row) { print_r($row); }
using NusaDb; await using var conn = new NusaConnection("Host=127.0.0.1;Port=5678;User=app;Password=change-me;Database=nusadb"); conn.Open(); using var cmd = conn.CreateCommand(); cmd.CommandText = "SELECT id, region FROM orders WHERE id = $1"; cmd.Parameters.Add(new NusaParameter("1", 1));
Three ways to get a server running
Container image
nusadb/nusadb:0.1.0-beta.16 for linux/amd64 and linux/arm64, with the server and the shell. The data directory is /var/lib/nusadb.
docker run -d --name nusadb \ -p 5678:5678 \ -v nusadb-data:/var/lib/nusadb \ -e NUSADB_USER=app \ -e NUSADB_PASSWORD=change-me \ nusadb/nusadb:0.1.0-beta.16 docker exec -it nusadb nusadb-cli --user app
From source
Rust 1.95 is pinned in the repository and rustup fetches it. The first build takes a few minutes. This is the way to run beta.16 outside a container.
git clone https://github.com/nusadb/nusadb.git cd nusadb cargo build --release ./target/release/nusadb-server \ --listen 127.0.0.1:5678 \ --data-dir ./data \ --auth-user app:change-me
Release archives
Prebuilt nusadb-server and nusadb-cli for Linux (x86-64, ARM64), macOS (Intel, Apple Silicon) and Windows (x86-64). The newest archives on GitHub are for 0.1.0-beta.14.
# TARGET: x86_64-unknown-linux-gnu, # aarch64-apple-darwin, ... tar xzf nusadb-v0.1.0-beta.14-$TARGET.tar.gz cd nusadb-v0.1.0-beta.14-$TARGET ./nusadb-server --data-dir ./data \ --auth-user app:change-me
Questions people ask first
Can I connect with a client written for another database?
No. NusaDB has its own wire protocol, and a client that sends another engine's handshake gets no answer, so it looks like a connection that hangs. Use nusadb-cli, one of the eight drivers, or write a client against the protocol specification. SQL written for other engines usually runs unchanged.
What happens on a crash?
Every transaction whose COMMIT returned is there after restart, and nothing of one that had not. The engine opens the last checkpoint image, loads pages from its segments as they are used, and replays the log written after it. Restart time grows with the log written since the last checkpoint, not with the size of the data.
Why did my transaction fail with 40001?
Locks do not wait. When two transactions write the same row, or a serializable transaction would see a result no serial order could produce, one of them fails with 40001 and should be retried. A single autocommit statement is retried by the server, up to max_autocommit_retries attempts (50 by default). Explicit transactions need a retry loop in the application; the transactions page has one in several languages.
Does my data have to fit in memory?
Table pages and B-tree index pages do not. They are loaded from segments on first use, evicted when clean and spilled when changed. Index entries larger than about 2 KB, notes for index entries awaiting purge, and HNSW vector graphs stay in memory. When those reach the bound, the next insert or update fails with an out-of-memory error rather than the process growing until the host kills it.
How do I back up a running server?
A checkpoint image with the segments it names is a consistent copy of one database, taken while the server keeps writing. --backup-dir takes hard-link snapshots of them on a schedule. For point-in-time restore, add --wal-archive-dir and rebuild offline with --restore-database and --restore-to-time. Copying backups off the machine is up to you.
Is it ready for production?
It is a pre-1.0 beta. The storage format is versioned and a newer release upgrades an older data directory in place, but interfaces can still change between releases, and the features on the limits page are not built. Read that page before deciding.
Which SQL does it accept?
Most of standard SQL that makes sense on one node: joins of every kind, subqueries, CTEs including recursive ones, window functions, grouping sets, MERGE, ON CONFLICT, triggers, SQL and NusaScript routines, views and materialized views, partitioned tables, sequences, and a wide type system. The statement index lists each statement with an example, and not accepted lists what is refused.