Architecture
This document describes how nonodb stores data, serves requests, maintains indexes, and survives failures. It is intentionally implementation-oriented: if you only want to use nonodb, start with the README and the HTTP API.
Design goals
Section titled “Design goals”nonodb is built around a small set of explicit goals:
- One local deployment, multiple databases, no external service. A single daemon owns the instance root and all of its database directories. Clients do not open LMDB.
- Safe for preforking servers. Any number of uvicorn/Gunicorn workers can connect over a Unix socket without sharing file descriptors or mmap state.
- Crash safety by default. A process kill must not corrupt the database.
- Predictable indexed reads. Lookup cost should be effectively independent of collection size when an index is available.
- A familiar document API. JSON documents, MongoDB-like filters, and a practical subset of update operators.
- Small operational footprint. One binary, one data directory, one socket, no JVM, no external cluster service, no separate cache.
- Explicit write semantics. One writer, group commit, and an explicit
all-or-nothing
write_batchinstead of general interactive transactions.
Non-goals are listed in Roadmap and limits.
Process model
Section titled “Process model” application processes daemon process ───────────────────── ────────────── uvicorn worker 1 ─┐ uvicorn worker 2 ─┤ HTTP/1.1 + JSON ┌────────────────────────────┐ ... ├────────────────────────▶│ axum/hyper accept loop │ uvicorn worker N ─┘ Unix socket or TCP/TLS │ │ │ read path: spawn_blocking │ │ write path: mpsc channel │ │ │ │ ┌──────────────────────┐ │ │ │ single writer thread │ │ │ │ group commit │ │ │ └──────────┬───────────┘ │ └─────────────┼──────────────┘ │ ┌────────▼─────────────────┐ │ LMDB environment per DB │ │ <db>/data.mdb, lock.mdb │ └──────────────────────────┘nonodb-daemon is the only writer. Administrative CLI commands may open a
database read-only for backup, inspection, or verification; restore runs with
the daemon stopped. Each database has its own environment and writer thread;
there is never more than one writer per environment. With multiple databases, reads and writes in different databases
are independent. See Multiple databases. Read requests are executed on
blocking worker threads (Tokio’s spawn_blocking); write requests are sent to a
dedicated writer thread over an mpsc channel. The HTTP layer never performs
storage work on the async runtime.
A client connection is stateless. There are no sessions, cursors, or transactions spanning requests. This is what allows the client to be a thin HTTP wrapper and makes worker restarts trivial.
Authentication and authorization
Section titled “Authentication and authorization”The daemon keeps the authorization registry outside LMDB in
NONODB_AUTH_FILE. It contains principals, per-collection scopes, token hashes,
and certificate fingerprints. Token secrets are never stored, and database
restores cannot roll back revocations.
- Unix sockets authenticate as the local administrator.
- TCP requires the registry and a bearer token, a registered client certificate, or both resolving to the same principal.
- Each request is authorized independently; batches are checked per operation before the write transaction starts.
- TLS handshakes reject unregistered certificates, and every request re-resolves the certificate so disabling an entry affects existing keep-alive connections.
- A file watcher swaps in valid changes atomically and keeps the last known good registry after an invalid edit.
- Optional JSONL audit records are append-only and outside the database.
See Authentication and authorization.
Storage engine: LMDB
Section titled “Storage engine: LMDB”nonodb uses LMDB through the
heed crate.
Properties that matter here:
- Memory-mapped B+ trees. Reads touch pages on demand; the OS page cache keeps hot data. The daemon’s own heap does not need to hold the data set.
- Copy-on-write. A writer never overwrites pages visible to a reader. Readers see a stable snapshot for the lifetime of their transaction.
- Single writer, many readers. LMDB serializes writers internally. nonodb makes that explicit with one writer thread.
- Crash safety. Committed transactions survive process death. An interrupted write leaves the last committed state intact.
- No WAL, no background compaction. The file grows to a high-water mark and
does not shrink.
backupwith compaction produces a smaller copy.
The default map_size is 1 GiB. This is a maximum address-space reservation
for the database, not an allocation of 1 GiB of RAM or disk. It can be raised
with NONODB_MAP_SIZE. The current file size grows as needed.
Data layout
Section titled “Data layout”An LMDB environment contains named sub-databases. nonodb uses this layout:
| Sub-database | Key | Value | Purpose |
|---|---|---|---|
meta |
metadata key | JSON or scalar | Collection registry, collection profile, index definitions, search totals, history sequence |
history |
collection + _id + revision |
revision JSON | Append-only document history |
ttl |
expiry index / collection + _id |
expiry timestamp | Document expiry metadata |
coll:<name> |
_id bytes |
JSON document | Primary collection data |
dbslot:<n> (index) |
encoded values + _id |
encoded _id / covering payload |
Secondary index |
dbslot:<n> (text postings) |
term\0_id |
term frequency (u32 LE) | BM25 postings |
dbslot:<n> (text lengths) |
_id |
document length (u32 LE) | BM25 normalization |
dbslot:<n> (fuzzy) |
trigram\0_id |
empty | Fuzzy candidate index |
dbslot:<n> (vector) |
_id |
norm + f32 components |
Exact vector index |
legacy idx:*, ft:*, ftl:*, fz:* |
as above | as above | Resources created by older releases |
Collection names are validated. A string _id is used directly as the primary
B+ tree key. An ObjectId _id uses a reserved high-codepoint UTF-8 prefix, which
sorts after ordinary strings and preserves BSON type ordering. Documents are
serialized with serde_json; reads use sonic-rs for faster parsing.
Dates use MongoDB Extended JSON ({"$date": {"$numberLong": "<ms>"}}) and are
canonicalized on write to UTC Unix milliseconds. Index encoding gives dates
their own type tag and an order-preserving signed integer payload, so range
filters, sorting, compound indexes, and unique constraints compare instants
rather than the original string representation. Date strings are not converted
implicitly. See Dates and time zones.
Numbers use one numeric type bracket. JSON integers, floats, $numberInt,
$numberLong, $numberDouble, Decimal128 ({"$numberDecimal": "..."}), and
special doubles (NaN/Infinity) are normalized to a bounded scientific
decimal representation for comparison and indexing. Integers are never rounded
through f64; floats use 17 significant digits; Decimal128 keeps up to 34
digits. See Numbers and decimals.
Binary/UUID values ($binary, $uuid) and ObjectId ($oid) are stored as
canonical Extended JSON objects. They have their own index tags and are compared
by subtype/length/bytes and by the 12 ObjectId bytes respectively. See
BSON scalar types.
The optional history sub-database stores immutable revision snapshots. A key
contains the collection name, _id, and a global rev assigned by the writer.
The current collection is never modified by history and history entries are
not indexed. See Document history.
The ttl sub-database stores expiry metadata separately from documents. It has
two key families in one named database: an expiry-ordered index
(e + expire_ms + collection + _id) for the sweeper and a direct
collection/_id lookup (i + collection + _id) for updates and deletes.
Collection defaults live in meta as ttl:<name>. TTL entries are written in
the same transaction as the document, indexes, and history. See
Document TTL.
Vault collection layout
Section titled “Vault collection layout”A collection profile is stored in meta as profile:<name>. Missing
means standard; the second supported value is vault.
A vault document stores only its primary key, tenant, and encrypted envelope:
{"_id":"...", "tenant_id":"acme", "_enc":{"v":1,"alg":"xchacha20poly1305","kid":"acme:v1","n":"...","ct":"..."}}The complete original document is encrypted into _enc.ct with
XChaCha20-Poly1305. AAD binds the ciphertext to collection name, tenant, _id,
and key id. _id and tenant_id stay plaintext so primary-key lookup and tenant
isolation do not require decrypting the whole collection.
Vault collections have no secondary, text, fuzzy, or vector indexes. Standard write methods reject vault collections, and vault requests require the three encryption headers. See Vault collections for the API contract and threat model.
Every collection consumes a named LMDB sub-database. Index, text, fuzzy, and vector
resources are assigned physical slot databases (dbslot:*) from a reusable
pool. Dropping a resource clears its slot and returns it to the pool, so
create/drop cycles do not consume additional LMDB sub-databases. MAX_DBS is
1024; the pool reserves 64 slots for collections and fixed databases.
Index/search resources created by older releases still use their legacy named sub-databases. They remain registered until a compacting backup/restore; recreated resources use the slot pool. See Operations.
Read path
Section titled “Read path”At a high level:
- The HTTP handler authenticates the connection, authorizes the requested scopes, and parses the request.
- A read task opens one
RoTxn(LMDB read transaction). - The collection resolves the cheapest access path:
- exact
_id→ direct B+ tree lookup; - usable secondary index → range scan over index entries;
- otherwise → full collection scan.
- exact
- A residual matcher verifies every candidate against the complete filter.
- The result is projected, sorted, paginated, and serialized.
A read transaction provides a consistent snapshot for the whole request. The
read-only batch operation reuses one RoTxn for all of its operations, so a
batch sees a single point-in-time view.
Query planning
Section titled “Query planning”The optimizer is intentionally simple and conservative. It uses an index when:
- the filter has an equality condition (or single-value
$all) on every field of a compound index prefix, with an optional range or anchored-regex prefix on the last field; or - a single-field index has an equality or range condition, a single-value
$all, or a case-sensitive anchored regex (^literal); and - the indexed field value is not
null(becausenullalso matches a missing field, which is absent from the index).
Even when an index supplies candidates, the full filter is evaluated against each document. Indexes are an access path, not a substitute for query semantics.
If the sort order exactly matches the full index order, nonodb can stream the
index without materializing and sorting a result set. This is the index-only sorted scan path.
Full scans and parallel scans
Section titled “Full scans and parallel scans”A full scan iterates primary keys in _id order. find_one and find without
a sort stop early once skip + limit matches have been produced.
A full-collection sort without a usable index is CPU-bound. For shallow
queries (skip + limit <= 50,000), nonodb splits raw primary-key/value ranges
into chunks and parses/filters them on up to 16 worker threads. Each worker
computes a bounded top-K heap; the coordinator merges them with a stable global
sequence number. Deep skips stay single-threaded to avoid keeping a large heap
per worker.
Unsorted scans use the same chunking with an adaptive wave coordinator. The
first wave is small, receives the results, and merges matches in _id order.
If it produced enough matches for skip + limit, the remaining chunks are never
sent, so broad filters keep the serial early exit. If not, later waves are
larger to amortize synchronization during a selective full scan. find_one
and very small limits stay on the serial path to avoid thread overhead.
String and boolean equality conditions also get a raw JSON prefilter. Before
deserializing a document, the scanner checks whether the serialized key and
value occur in the stored bytes. A miss skips the document entirely; a hit
still runs the full matcher, so false positives are harmless and there are no
false negatives. Numeric and null conditions are always left to the parser
because their equality semantics do not map safely to raw bytes.
Primary-key ranges
Section titled “Primary-key ranges”An _id equality or range ($gt, $gte, $lt, $lte) is executed directly
on the primary B+ tree, even when the filter has additional fields. This is not
a secondary index, but it narrows a scan to a contiguous key range. find,
count, update, and delete all use this path. Sort by _id can stream the
range in either direction and stop after skip + limit.
Clients can split a large non-indexed scan into disjoint _id ranges and issue
them concurrently; each request reads only its range.
Aggregation
Section titled “Aggregation”Aggregation is implemented in nonodb-core/src/aggregate.rs and is strictly
read-only. The daemon runs it in a blocking task with one RoTxn. A safe
pipeline prefix is pushed into find_in: a leading $match, then a contiguous
$sort+$skip/$limit, a simple $project, and $skip. This reuses secondary
indexes, primary-key ranges, covering projections, index-only sorts, and the
query-level TopK. $sort is only pushed when a following $limit keeps the
TopK heap small; otherwise the in-memory sort_by path is faster. A lone
$count after $match calls count_in and never materializes documents.
The remaining stages are evaluated in memory. Intermediate results are capped
at 100,000 documents to keep memory bounded; this is a deliberate first-version
limit rather than a query-planning restriction. $sort reuses the same document
comparator as find, and expressions reuse the path helpers used by filters and
updates. $addToSet and grouping keys serialize values to canonical JSON
strings for deduplication and grouping.
SQL is a thin parser and translator in nonodb-core/src/sql.rs. A SELECT
becomes a normal aggregation pipeline: WHERE becomes a leading $match,
GROUP BY/aggregates become $group, DISTINCT becomes a grouping stage,
HAVING becomes a post-group $match, and expressions translate to aggregation
expressions. The final stages project, distinct, sort, skip, and limit. Simple
field-only selects skip the aggregation engine entirely and call the normal
find path, inheriting its index bounds, early exit, and explain output.
explain_sql returns either the find plan or the generated pipeline.
INSERT, UPDATE, and DELETE are translated to insert_one_txn, the normal
update operators, and delete_txn. UPDATE SET expressions are evaluated per
document using the aggregation expression evaluator when they reference document
fields. The writer executes each SQL write statement in its own isolated LMDB
transaction, so a multi-row INSERT, a multi-document UPDATE, or a DELETE is
atomic and still goes through the single writer. SQL therefore shares index maintenance,
TTL handling, history, aggregation limits, and authorization with the JSON API.
Updates resolve paths before writing. Numeric segments address array indexes;
$ expands from the original update filter, $[] expands to every element,
and $[identifier] expands only to elements matching the corresponding
arrayFilters entry. Path expansion happens on a copy of the document inside
the write transaction, so validation or update errors never persist partial
changes. $push applies $position, then $sort, then $slice, matching
MongoDB’s ordering.
Choosing a read strategy
Section titled “Choosing a read strategy”The explain operation reports the selected path, index and bounds, sort
coverage, candidate count, and exact matched/returned counts. It executes the
query to provide actual counts, so use a small limit for broad filters.
Use the cheapest access path that fits the query:
- Exact
_id— direct primary-key lookup, ~sub-millisecond. - Secondary index — for equality/range filters and supported sorts.
_idrange — split a large scan by primary key, or cover time-ordered custom ids.- Partitioned collections — keep hot tenants, months, or types in separate collections so a query touches only the relevant subset. This is an application-level index with no engine changes.
- Full scan with raw prefilter — fallback for ad-hoc predicates.
- Daemon read cache — repeated identical reads, bounded TTL and invalidated after every committed write.
For frequent queries, indexes and collection partitioning remain the only approaches that avoid linear scans.
Automatic indexes
Section titled “Automatic indexes”Automatic indexing is an opt-in optimization layer, not a replacement for
schema design. It is disabled by default and must be enabled with
NONODB_AUTO_INDEX=1.
The daemon maintenance worker keeps in-memory frequency counters for cache-missed read shapes:
collection + set of indexable fields + equality/range classificationConcrete values are deliberately not part of the key. A shape becomes a
candidate after NONODB_AUTO_INDEX_MIN_HITS misses inside a rolling window.
The maintenance worker then checks the collection size, existing indexes,
limits, and write queue, and asks the normal writer to create the index:
read cache miss ──▶ shape counter ──▶ candidate │ ▼ maintenance worker (auto-index) │ CreateIndex / DropIndex ▼ writer threadThe full scan path, raw prefilter, and read cache remain in place. If an automatic index is dropped or cannot be built, queries still return correct results through the fallback path.
Automatic indexes are marked in auto-index.json in each database directory
(for example NONODB_DATA/default/auto-index.json). Only
those indexes are eligible for TTL eviction; manually created indexes are never
removed. Demand is recorded even on cache hits so a hot query does not lose its
index merely because the cache is serving it.
The same maintenance worker also drives TTL sweeps and history pruning. It never opens a write transaction itself; every mutation is submitted to the single writer.
Important limitations:
- automatic index creation uses the normal single-writer path; queries keep using the existing scan/cache fallback until the index is available;
- creation is skipped when the write queue is backlogged;
- only simple equality/range predicates are considered;
- there is no selectivity histogram yet, so very broad indexes can be created if the query is frequent enough;
- sorting-only queries and
$orshapes are not auto-indexed.
Maintenance worker
Section titled “Maintenance worker”One background thread coordinates low-priority maintenance:
- TTL sweeper: reads due entries, submits an
Expirejob to the writer, and re-checks the expected expiry under the write transaction; - history pruning: submits a bounded
PruneHistoryjob every 30 seconds; - automatic indexes: runs the conservative candidate/eviction logic on its own interval.
The worker is intentionally not a second LMDB writer. This keeps the single writer model, group commit, and crash-safety guarantees intact.
Write path and group commit
Section titled “Write path and group commit”All writes go through a channel to one writer thread:
request A ─┐ request B ─┼──▶ mpsc queue ──▶ writer thread ──▶ one RwTxn ──▶ commit (fsync) request C ─┘ collect up to 512 jobs / adaptive windowThe writer waits for the first job, then collects more jobs for a short window:
- 1 ms when the queue is short (low latency);
- 3 ms when at least 64 jobs are queued;
- 5 ms when at least 256 jobs are queued.
It executes the collected requests in one LMDB write transaction and commits
once. The fsync cost is therefore amortized across many requests. Responses
are sent only after the commit succeeds.
Two details are important:
write_batchis isolated. An atomic batch must not share a transaction with unrelated requests: if one operation fails, the whole batch must roll back without rolling back someone else’s write. The writer executes an atomic batch in its own transaction.- Read-only
batchnever enters the write queue. It runs entirely on the read path with oneRoTxn.
There is no general interactive transaction API. If you need a set of writes to
be all-or-nothing, use write_batch.
Indexes
Section titled “Indexes”Key encoding
Section titled “Key encoding”Secondary index keys are ordered so that LMDB byte ordering matches logical ordering:
- scalar values are tagged by type and encoded in an order-preserving form;
- numbers are encoded as an exact, order-preserving scientific decimal with one numeric type tag for integers, floats, Decimal128, and special doubles;
- strings are escaped UTF-8;
- Extended JSON dates are encoded as order-preserving signed millisecond integers with a separate type tag;
- binary/UUID keys encode subtype, length, and bytes; ObjectId keys encode 12 bytes, each with a separate type tag;
- compound keys concatenate encoded fields;
- the document
_idis appended to make each key unique.
Because the encoding is ordered, range queries ($gt, $gte, $lt, $lte)
become contiguous LMDB ranges. An index range scan does not deserialize
documents until candidates are verified.
Secondary indexes accept strings, numbers, Decimal128, special doubles,
booleans, dates, binary/UUID, ObjectId, and null values that are actually
present. Arrays and ordinary objects are skipped. Dates are canonicalized
before indexing, so all offsets for one instant share a key. Text and fuzzy
indexes search string, boolean, and numeric scalar values, including Extended
JSON integer/double/decimal forms. Dates, binary/UUID, and ObjectId values are
not searchable text.
Index definitions record the key-encoding format. Definitions written before
date support default to format 0 and are not used for filters containing dates,
because those indexes skipped $date objects during backfill. Version 2 used
the old f64 numeric transform; version 3 uses exact numeric keys; version 4
adds binary/UUID and ObjectId keys; version 5 adds multikey array entries.
Indexes older than the current format are not used by the planner; recreate
them after upgrading to include all values.
Compound indexes
Section titled “Compound indexes”fields: ["tenant", "kind", "created_at"] creates an index named
tenant+kind+created_at. The optimizer can use:
- equality on
tenant+ equality onkind+ a range oncreated_at; - equality on a prefix, followed by an index-order sort.
It does not attempt arbitrary index intersection or multi-index plans.
Unique indexes
Section titled “Unique indexes”A unique index rejects a document whose full indexed key already exists. For a compound unique index, uniqueness applies to the complete key, not to each field separately. A unique multikey index accepts repeated elements inside the same document but rejects the same key in another document. Uniqueness is checked during inserts, updates, and backfill.
Covering indexes
Section titled “Covering indexes”include: ["name", "status"] stores those fields in the index value alongside
the _id. If a query’s projection is fully covered by the indexed fields and
the included fields, the daemon can build the result without reading the
document. Otherwise it falls back to fetching the document.
Covering is used only for inclusive projections. An exclusive projection always needs the full document.
Index maintenance and backfill
Section titled “Index maintenance and backfill”Indexes are updated in the same transaction as the document. Creating an index on a non-empty collection triggers a synchronous backfill:
- the main thread reads bounded raw key/value chunks through the active write transaction;
- worker threads parse JSON and encode index entries in parallel;
- the main thread applies each completed chunk immediately in that same write transaction instead of buffering all entries;
- chunks are capped by document count and 4 MiB of raw bytes, and the worker queue is bounded, so peak heap does not grow with collection size;
- unique indexes detect duplicates by reading the LMDB prefix that is already written, avoiding a collection-sized in-memory key map;
- duplicate-key and parse errors are reported without deadlocking workers.
Because the index build holds a write transaction, it blocks other writers for its duration. On large collections, raise the client and server timeouts.
Full-text search
Section titled “Full-text search”A text-index definition (SearchIndexDef) is stored in metadata under
search:<coll>:text:<name>. A definition may cover multiple fields with
weights; the native single-field helpers use the field name as the index name.
Each indexed field has:
ft:<coll>:<index>:<field>— postingsterm\0_id → term frequency;ftl:<coll>:<index>:<field>— document lengths for BM25 normalization;fttotal:<coll>:<index>:<field>— total token counter.
Queries tokenize the search string, look up postings for every term, compute
BM25 scores (k1=1.2, b=0.75), merge scores by document, and sort descending.
The semantics are OR over positive terms; BM25 decides the ranking.
Duplicate query terms are removed. Negative terms and phrases are applied as
exclusions by the MongoDB $text path.
Quoted phrases are parsed separately. A document must contain each phrase as a
contiguous token sequence. Phrase words still participate in scoring, and the
phrase check is applied before skip/limit. An optional residual filter is
also applied before pagination.
Tokenization:
- Unicode lowercase;
- diacritic folding (NFD, removal of combining marks, plus
ł/ø/đ/ßmappings); - maximal runs of alphanumeric characters;
- punctuation and whitespace are separators.
There is no stemming and no stop-word list.
Fuzzy search
Section titled “Fuzzy search”A fuzzy-index definition is stored under search:<coll>:fuzzy:<name> and its
postings use fz:<coll>:<index>:<field>. create_fuzzy_index stores unique
trigrams for the field value. A query:
- normalizes the query;
- collects documents sharing at least one trigram;
- ranks candidates by shared-trigram count;
- caps candidates at 5,000;
- computes bounded Levenshtein distance to the whole normalized value or to the closest token;
- returns matches with distance ≤
max_distance(default 2), sorted by_distancethen_id.
Trigrams are an index for candidate generation, not the final distance. The final Levenshtein comparison is exact within the requested bound.
Vector search
Section titled “Vector search”create_vector_index stores one value per indexed document in a dedicated
sub-database:
- key:
_id; - value:
f32norm followed bydimslittle-endianf32components; - definition in
meta: field, dimensions, metric, and format.
The index is maintained in the same transaction as the document. A query:
- validates the query dimensions and filter;
- scans every stored vector;
- computes cosine, dot, or squared L2 distance;
- keeps a bounded top-K heap by
_distanceand_id; - applies an optional residual filter before ranking;
- fetches only the selected documents and adds
_distance.
This is exact brute force (O(N × dims) per query), not an ANN index. It has
no training, graph maintenance, or recall tuning, and all vector data lives in
the same LMDB file as the rest of the database. Embeddings are generated by the
application or a separate embedding service; the daemon does not run a model.
Concurrency and consistency
Section titled “Concurrency and consistency”- Readers never block readers. MVCC snapshots.
- Readers do not block the writer. A writer creates new pages; old pages remain valid for active readers.
- Writers are serialized. One writer thread and LMDB’s single-writer model.
- No cross-request isolation. A read-modify-write sequence performed as two
separate requests can interleave with another client. Use
find_and_modifyfor an atomic select-update-return, update operators such as$inc, or group writes inwrite_batch. - Read-only
batchis a snapshot. All reads in a batch see the same state. write_batchis all-or-nothing. A failure at any operation rolls back the whole batch.- Daemon read cache is shared and invalidated on commit. It is bounded by TTL, entry count, and value size. It never survives a committed write.
- Client cache is opt-in and local. It is invalidated on writes through the same client instance and bounded by a TTL; it cannot provide cross-process freshness.
Crash safety
Section titled “Crash safety”LMDB’s copy-on-write design means a crash can leave at most the last uncommitted transaction incomplete. The previous committed root remains valid. On startup, nonodb clears stale reader slots and opens the environment again.
The daemon does not need a repair step after kill -9. Tests kill the process
during active writes and verify that:
- the database opens;
- all documents from committed batches are readable;
- indexes still agree with the documents;
- new writes succeed after restart.
The lock.mdb file is part of the LMDB environment. Do not copy it into a
backup or restore it as data. nonodb-cli backup copies a consistent LMDB
snapshot, and restore removes the stale lock file.
Memory and disk behavior
Section titled “Memory and disk behavior”- RSS reflects pages actually touched by the process and the OS page cache attributed to mapped pages. An idle daemon with a small working set is typically a few megabytes of RSS.
- Virtual size includes the
map_sizereservation and is much larger than RSS. This is normal and is not a memory leak. - Full scans and large sorts can raise RSS substantially while the process touches many mapped pages. Restarting the daemon drops process RSS, but the OS may keep pages cached.
- The LMDB file never shrinks. Deletes leave free pages. A compacting backup produces a smaller copy; restoring it reduces the working file size.
See Operations for concrete measurements and tuning guidance.