Skip to content

How OliviaDB stores data

OliviaDB is a hierarchical database. You describe your data as aggregates: a root record with its children, their children, and so on. Each aggregate is stored on disk as one contiguous run of keys, in the order you would walk the tree. That one layout decision is where the rest follows from.

Aggregates

An aggregate is the unit your application already thinks in: a customer with its accounts, cards and transactions; an order with its lines; a policy with its claims. In the schema language (.olv, specification) it reads like this, shortened from the specification's example bank.olv:

aggregate Customer {
  key id: string(12)
  1 name:    string(80)
  3 branch:  string(4)

  child Account [number: string(20)] unique {
    2 balance:  decimal(18,2)

    child Txn [posted: timestamp desc, seq: int32] {   // newest first
      1 amount: decimal(18,2)
    }
  }

  child Card [pan: string(19)] unique {
    1 account: ref ../Account
  }
}

index card_by_pan on Customer/Card(pan) unique

A child type has its own key (Account [number]), or is ordered when it has none. Fields have fixed types, so every record has a known layout.

Path keys: the tree is the key order

Every record is stored under a path key: one component per level, root first, each component made of the record type's code and its key (path keys). Keys compare as byte strings, which gives three properties:

  • a record's key is a prefix of the keys of all its descendants, so a parent sorts before its subtree and every subtree is one contiguous key range;
  • siblings sort by type, then by key;
  • the byte order of all keys is the pre-order walk of the trees.

For a customer that looks like this:

A customer as a tree, and the same records as path keys in key order on disk The aggregate Customer 42 Account 1001 Txn 2026-12-03 #1 Txn 2026-12-01 #1 Account 2207 Card 4417… On disk: one ordered run of keys Customer/42 Customer/42/Account/1001 Customer/42/Account/1001/Txn/2026-12-03/1 Customer/42/Account/1001/Txn/2026-12-01/1 Customer/42/Account/2207 Customer/42/Card/4417… one range read

A customer as a tree, and the same records as path keys, in key order on disk

As paths:

Customer/42
Customer/42/Account/1001
Customer/42/Account/1001/Txn/2026-12-03T10:14/1
Customer/42/Account/1001/Txn/2026-12-01T08:02/1
Customer/42/Account/2207
Customer/42/Card/4417…
Customer/43
…

(The keys are binary on disk; they are shown here as paths.)

What follows from the layout

You want On tables On OliviaDB
A whole customer a lookup per related row in each table, then a join to rebuild it one range read from Customer/42 to the end of its subtree
A customer's accounts only an index lookup on account.customer_id the range of keys starting with Customer/42/Account
The next record in the hierarchy a query per level the next key
Skip a subtree – one seek past every key that starts with that record's key
A page of customers an index scan, then more queries for their children one range over the roots; their subtrees are not read

Writing a new transaction under an account adds one key in that range. Nothing else moves, and the rest of the customer stays available to other writers.

Transactions

Every write is a serializable transaction. Several writes commit together, all or none (POST /v1/txn, HTTP API by example). Transactions are optimistic: on a conflict the server retries, and after three conflicts it takes locks. A transaction writes within one aggregate record (txn scope aggregate, the rule of domain-driven design); transactions across records are refused for services and agents until the distributed engine (OliviaDB Enterprise, in development) brings them (network API). Moving value between two records is done with idempotent steps (transfers).

Secondary indexes are declared in the schema (index card_by_pan …) and kept with the data, synchronously or asynchronously. A listing of one child type reads only that type's keys. Text search ranks the records a caller may read. See the network API.

Access is part of the schema

A profile says which aggregates, fields and rows a client may read or change, which fields are masked, and what its transactions may span. Profiles are enforced by the server for applications and AI agents alike (agent data access, MCP).

DL/I is the same model

IMS hierarchical databases are trees of segments in hierarchic sequence, which is exactly the path-key order. That is why programs calling CBLTDLI run against OliviaDB unchanged: "get next" is "next key" (DL/I quick start).

Growing past one machine

Because keys are ordered and a subtree never straddles a cut, the key space divides into ranges at aggregate boundaries. Today a server runs on one node, with a standby for high availability (high availability). Ranges replicated with Raft, with transactions across ranges, are the plan for the distributed engine, in development for OliviaDB Enterprise (multi-Raft plan).