Skip to content

Designs considered and not built

Choices that were weighed against measurements and set aside, with what would bring them back.

Type-clustered keys for native aggregates (2026-12-03)

The question. A native aggregate is stored in pre-order: a node's key is a prefix of every key of its subtree, so a subtree is one key range (spec/path-keys.md). Reading an aggregate record whole (the benchmark's dossier: a customer, 2 accounts, 200 transactions, a card) is one range read. Listing the nodes of one type under one parent (the page workload: 50 customers) is not: between two customers lie the first one's 200 descendants, so the listing seeks past each customer's subtree, 50 seeks per page, each over every level of tables that holds the range. PostgreSQL reads 50 consecutive rows of its customer table.

The alternative. Keys for native aggregates ordered by type first:

node key = "a" tenant 0x00 aggregate 0x00 type-path 0x00 component+

so that each type (Customer, Customer/Account, Customer/Account/Txn, ...) is one key range, as a table is, or as Spanner tables are when they are not interleaved. Listing a type under a parent becomes one range read.

What it costs, by operation (per aggregate record of the benchmark's shape):

operation pre-order (today) type-clustered
read a record whole (tree=true) 1 range 1 point read + 1 range per descendant type and parent: Account (1), Txn (1 per account: 2), Card (1): 5 seeks
list children of one type 1 seek per child 1 range
delete a subtree, erase a data subject 1 range delete 1 range delete per descendant type and parent (as above)
insert or update a node 1 key 1 key
change stream, backup, replication unchanged unchanged

The write path is the same (one key per node); the change moves cost from listings to whole-record reads and subtree deletes. A seek costs about 1 µs per level of tables in process (the probe in open/crates/oliviadb-server/src/native/probe.rs), so a whole-record read would pay about 4 more seeks; the listing would save 49.

What it does to DL/I. Nothing: DL/I databases keep format 1 and pre-order, the order in which OliviaDB keeps hierarchic sequence for GN (spec/path-keys.md, "Order"). The change could only apply to native aggregates, which would then differ from DL/I databases in their physical order.

Why not now. Measured on core page-fast in 4-CPU containers (docs/benchmarks.md, 2026-12-03): the whole-record read is OliviaDB's strongest workload (1.55 times PostgreSQL's throughput); the listing is at 0.80 to 0.82. Most of the listing's remaining cost is the search inside blocks during each seek (44 % of the read in a profile), which can be made cheaper without changing the storage format. Type clustering would trade the first for the second and change the format of every native store (a migration for each).

What brings it back. If the block-level work (prepared restart entries, cheaper index probes, a shorter restart interval) does not bring listings to PostgreSQL's level in the containers, this is the next design to prototype: behind a schema-level option, measured in process on whole-record reads, listings and subtree deletes before any format change.