Documentation / Limits and capacity
Limits and capacity
Constraints of this release that affect how a deployment is sized and operated, and features that are not built yet.
What still has to fit in memory
Table pages live in a page cache backed by the last checkpoint image. A page is loaded from the image's page segments on first use, a page unchanged since the last checkpoint can be evicted when memory is needed, and a changed page spills to a scratch file beside the log when there is nothing clean left to evict. The cache is bounded by --max-resident-bytes, or by a value derived from the detected memory budget when the flag is unset. A table scan reads a batch of rows at a time, and B-tree indexes, the primary key's included, live in pages too, so neither has to fit in memory.
Two kinds of data cannot leave memory: index entries too large for an index page (a key of roughly 2 KB or more), and a note per index entry an UPDATE moved to a new key, kept until the background purge removes the old entry. Once these reach the bound, the next insert or update is refused before it starts:
ERROR XX000: out of memory: the engine reached its resident-memory limit of 858993440 bytes (859001088 bytes held by index entries); free rows (DELETE/TRUNCATE), drop indexes that are not needed, raise the limit, or use a larger host
Related behaviour:
- A long-running transaction delays the purge, so heavy key-changing updates under one can grow the notes that count against the bound.
- If the scratch file cannot be written (a full disk), changed pages stay in memory and the cache grows past the bound until the next checkpoint instead of failing the write.
- Vector indexes (
USING hnsw) are held in memory whatever the bound. A large vector index needs the memory for its whole graph.
DELETE, TRUNCATE, CREATE INDEX and the background purge are not refused at the bound, so space can always be freed. See configuration for the full picture.
The log grows until a checkpoint
The write-ahead log is the durable copy of the data. A checkpoint writes the pages changed since the last one into a new page segment, publishes a new image, and truncates the log, so the data directory holds live data plus the write history since the last checkpoint. A checkpoint is taken when a database is opened with a log past a few megabytes, on demand with the CHECKPOINT statement, and by a background worker once a database's log passes --checkpoint-threshold-bytes (64 MiB by default).
A checkpoint needs a moment with no transaction active. Under continuously overlapping transactions the worker briefly holds new ones (at most --checkpoint-max-pause seconds) so it can run. A transaction held open longer than that, such as an idle client inside BEGIN, defeats the pause, and the log keeps growing until that transaction ends. See configuration.
Restart time tracks the log tail
Recovery opens the last checkpoint image, loads pages from it only as they are used, and replays only the log after it, so start-up time grows with the writes since the last checkpoint, not with the size of the data or its whole history. The background checkpoint worker keeps that tail near its threshold; a transaction left open for a long time lets it grow, and so does a server run with the worker turned off.
Backup, point-in-time recovery and standby
A checkpoint image together with the page segments it names is a consistent copy of one database, even while the server keeps writing, and a hard-link snapshot of them takes milliseconds. With --wal-archive-dir, every checkpoint also archives its log segment and image, and a database can be rebuilt offline as of a moment or a log position with --restore-database. A second server started with --standby-from follows a primary through that archive and serves reads.
Backups and archive retention are built in (--backup-dir, --wal-archive-retain); copy the backup directory off the machine yourself. The standby lags the primary by its checkpoint cadence, because a segment reaches the archive only when the primary checkpoints; it is read-only, and promotion is a manual restart without --standby-from. See configuration for the recipes.
Single node
The engine runs on one machine. There is no clustering and no automatic failover: the availability of the deployment is the availability of that host and its disk, plus a standby you promote by hand.
One server per data directory
A running server holds an exclusive lock on global/cluster.lock in its data directory, and each open database one on its own lock file. A second server started on the same directory exits at once with a message naming the lock. The operating system releases the locks when the holder ends, even when it is killed, so there is no stale lock to remove by hand. Keep the data directory on a local file system: on some network file systems these locks are not enforced across machines.
A storage error stops that database
If reading or writing a page fails while a change is being made (a damaged page on disk, an unreadable page of the scratch file, a full disk under a ROLLBACK TO SAVEPOINT), that database stops rather than persist a half-made change. Every later statement against it fails with XX000 and a message saying the database stopped after a storage error, and the metrics endpoint reports nusadb_database_stopped{database="..."} 1; the stopped database never checkpoints, so its image stays as the last good checkpoint left it. Other databases on the same server keep serving. After fixing the cause, restart the server: the database is rebuilt from its last image and its log, with every committed transaction and nothing of the interrupted one. An error while a statement only reads a page fails that statement alone.
Query memory and spilling
With --work-mem set and a --spill-dir configured (a Linux host with a detected memory budget gets both by default), a query whose working set exceeds the budget streams the overflow to disk instead of failing. That covers sorts, DISTINCT, DISTINCT ON, GROUP BY including ROLLUP / CUBE / GROUPING SETS, set operations, hash joins and window functions; CREATE TABLE AS, materialized views and INSERT ... SELECT stream their rows; a cursor keeps a large result on disk; and UPDATE ... FROM, DELETE ... USING and MERGE read their target as a stream and split a large source into partitions joined one at a time. Without a spill directory a stage over the budget fails with an error naming the limit and the flag, and the server stays responsive.
What still has to fit the budget: a window frame of an aggregate that holds its rows (one with EXCLUDE, a floating-point sum or avg, array_agg, or a min / max over values that keep rising across a very wide frame), a RANGE / GROUPS frame with an offset wider than the budget, and a cursor over UNION, INTERSECT or EXCEPT. An UPDATE or MERGE that sets a UNIQUE or primary-key column holds the table's new image to check it, and every write is held until its transaction commits. Without a budget, a large enough query can exhaust host memory.
Two more per-client bounds exist: --max-txn-write-bytes caps one transaction's uncommitted writes and --copy-max-bytes caps one bulk load. Both default to values derived from the memory budget, and exceeding either fails that client's statement with an error while the server keeps running.
Vector index build cost
Vector search is available with a VECTOR(n) type, four distance operators, and an HNSW index whose recall reaches exact-search results at a high enough hnsw_ef_search. Building the index is slow, so schedule index builds instead of running them during a load. The graph is saved as it changes and reloaded at open rather than rebuilt, and it is held in memory whatever the resident bound.
Not in this release
| Area | Status |
|---|---|
| Scheduled backup | Built in: --backup-dir, --backup-interval, --backup-keep, and archive retention with --wal-archive-retain. Copying backups off the machine is yours to arrange. |
| Encryption at rest | Built in, opt-in: --encryption-key-file encrypts each database's log, checkpoint image, page segments, scratch and spill files, archive and backups with AES-256-GCM-SIV. An existing data directory is encrypted by copying it with --encrypt-from. See configuration. |
| Clustering and automatic failover | Not built. A read-only standby follows through the checkpoint archive; promotion is a manual restart. |
| Synchronous replication | Not built. A commit is acknowledged without waiting for a standby, which receives the change only when the primary checkpoints. |
| Vector indexes larger than memory | Not built. USING hnsw graphs are held in memory whatever the resident bound. |
| DDL in a prepared transaction | Refused (0A000): a transaction that changed the schema, a sequence or statistics, wrote a temporary table, ran LISTEN / UNLISTEN / NOTIFY or declared a cursor WITH HOLD cannot be prepared. See two-phase commit. |
| Arrays of a composite type | Not supported yet. Composite types nest inside each other and may hold arrays of built-in types. |
MERGE into a partitioned table | Refused (0A000); merge into its partitions. INSERT ... ON CONFLICT, an UPDATE that moves a row to another partition, and PRIMARY KEY / UNIQUE keys that leave out the partition key are supported. |
Unique indexes and EXCLUDE constraints on a partitioned table | Refused (0A000); declare a UNIQUE constraint on the table, or create the index or constraint on each partition. |
Deferrable CHECK constraints | Refused (0A000). PRIMARY KEY, UNIQUE, foreign key and exclusion constraints can be DEFERRABLE. |
| Named time zones | SET TIME ZONE takes UTC or a fixed offset; an IANA region name is refused (no time-zone database, so no daylight-saving rules). |
| Locale collations | Refused; byte ordering only. |
| Index methods | Every scalar index is served by the B-tree (hash / brin are recorded, gin / gist / spgist fall back); hnsw is the vector index. |
Full-text configurations beyond simple, english and indonesian; prefix matching | Refused. |
| Password changes without a restart | Passwords live in --auth-user; change one by restarting. |
| Latency and storage metrics | Four server counters and a per-database stopped gauge only. |
| The .NET driver on NuGet | In the source tree, not yet published (Java is on Maven Central as com.nusadb:nusadb-jdbc). |
Where NusaDB fits today
This release suits deployments where one node with a read-only standby promoted by hand is acceptable, and where the operator copies backups off the machine. Table and B-tree index data can outgrow memory; vector indexes need memory for their whole graph.
It does not yet suit deployments that need failover without an operator, a standby that lags the primary by less than its checkpoint cadence, or backups that leave the machine without the operator copying them. The commit history lists what each release adds.