Why ChloeDB is fast
It does less work per query. Indexes are read in place from one file, laid out for the CPU, and every top-k loop skips what cannot rank. Each idea below links its code and one measured number.
Four habits, in every index
Opening maps the file. Every index is an aligned view of its bytes; nothing is decoded to open it.
Posting lists AND and OR 64 documents a word, columns are bit-packed in SIMD lanes, vectors score as 8-bit integers.
Exact score bounds, zone maps, vector error bounds and Bloom filters let each loop skip work it can prove useless.
Each segment chooses its indexes from exact statistics, and measures a vector filter near the query.
From SQL to rows in six steps
The same path in one process and on every shard.
- 1 · ParseParse once
A statement seen before skips parsing.
query/sql.rs - 2 · BindOne tree, one scorer
query/logical.rsWHEREbecomes text, column, vector and graph leaves. - 3 · GraphsWalk first
Traversals leave each segment an exact set of rows.
graph/traverse.rs - 4 · PlanPer segment
Each segment picks how to filter and which index ranks.
query/plan.rs - 5 · RunZero-copy
Operators read the mapped sections, on one shared thread pool.
query/pool.rs - 6 · MergeMerge, fuse, join
Top-k lists merge; large joins and groups go to DataFusion.
query/exec.rs
Storage
one file of immutable segmentsEvery index lives in segments written once and merged in the background, as in Lucene and Tantivy, for the whole table, in one file plus a write-ahead log.
MADV_RANDOM: a cold fault reads one pageread-ahead read in runsCommits by shadow paging
A commit writes new pages, then flips one of two checksummed meta slots. No rollback journal; small transactions append to the WAL.
Measured4.1 ms for a durable one-row commit; 98,000 rows a second in 1,000-row transactions.M2 · results
Sections used where they lie
Sections are 64-byte aligned, so a &[u64] view is taken straight from the mapping. A query opens only the fields it uses.
MeasuredA cold open takes 6.8 ms with 10 segments, 40 ms with 100.M2 · results
A page-cache hint per section
Sections read at random skip the kernel's read-around, and an HNSW search prefetches each hop's neighbours.
MeasuredA cold HNSW query on Quora: 136 ms by default, 113 ms advised, 28 ms with prefetching.M2 · results
New rows searchable at once
Commits fill 1,024-row chunks, built into small segments only when a query needs them. Readers pin a snapshot and never wait.
MeasuredThe first query after a write: 17 to 20 ms, against 169 ms for an unchunked memtable of 10,000 rows.M2 · results
Full text
dictionary, Loom lists, MaxScoreThree made-up posting lists of 64 rows in blocks of 8 (ChloeDB's blocks hold 128). Each bar above a block is the best score in it. Once the top 3 is full, a row whose blocks cannot beat the third is skipped, and a word whose best cannot lift a row alone stops driving the search.
A dictionary walked as a trie
A typed word skips every run of terms already too many edits away, computing 63 letters of edits at once in a machine word.
Measured1.4 ms with one edit among ORCAS's 797,472 terms, against 77 ms testing every term.Xeon VM, 2.10 GHz · typos
Loom posting lists
Long lists are cut into bitmaps, Elias-Fano runs and ranges on one shared word grid, so two lists AND and OR word by word.
MeasuredConjunctions 7.6 to 11× faster than BP128 lists, and 2 to 4% smaller.M2 · results, the study
Exact bounds, then MaxScore
Each list and each 128-posting block carries its best possible score, so lists that cannot lift a row past the threshold only confirm candidates.
MeasuredWarm BM25 top 10 is 1.7 to 3.2× faster than Tantivy 0.26 on four BEIR collections.M2 · results
The same score everywhere
BM25 statistics are summed over segments and shards, so a row scores the same wherever it lives. A CI gate holds relevance to committed numbers.
MeasuredWithin 0.018 nDCG@10 of Tantivy and SQLite FTS5 on four BEIR collections.M2 · results
Columns and keys
bit-packed blocks, zone maps, Pyramid listsEach structured field is stored twice: a column answers "what is this row's value", and a list per value answers "which rows have it".
Columns in 128-row blocks
Frame-of-reference, bit-packed in four SIMD lanes; reading a row is two loads and a shift. Zone maps skip 4,096 rows per check.
Pyramid lists per value
Equality and IN are set operations, with an O(1) membership test at any density. Ranges use a 64-bucket histogram that also feeds the planner.
MeasuredUnions faster than Roaring on the clustered collection, in 24 to 33% less space.M2 · the study
A read by key in a cache line
Sorted key hashes under a radix directory, plus a Bloom filter per segment, so a lookup skips the segments that lack the key.
Vectors
SQ8 and RaBitQ codes, HNSW, IVFAn HNSW graph of 90 made-up points in two dimensions. A search enters at the top layer, steps to whichever neighbour is nearer the query until none is, drops a layer, and on the bottom layer keeps the 8 nearest it has seen. Click the bottom layer to place a query.
Integer dot products
Vectors are scanned as 8-bit codes with VNNI or usdot instructions, chosen at run time; float32 rows rerank the last candidates.
Measured14 ns for a 1,024-dimension code against 70 ns in float32; codes alone find 99.8% of the exact top 10.M2 · results
HNSW on codes
The graph is built and searched on the 8-bit codes, a byte per dimension instead of four.
MeasuredRecall@10 0.990 at 0.086 ms on Quora's 522,931 vectors.M2 · design
Merges keep the graph
A merge keeps its largest input's graph and joins the others to it, as Lucene does, instead of building from scratch.
Measured12.2 s instead of 37.9 s for four TREC-COVID segments, at recall@10 0.987 to 0.989 against 0.992 to 0.993.Xeon VM, four threads · design
RaBitQ codes
Optional 1, 2 or 4-bit codes with an error bound: a float row is read only if it could still make the top k.
MeasuredOn FiQA, 28 float reads a query instead of 320, recall@10 0.996, 0.49 ms.Xeon VM, 2.80 GHz · results
The planner
per segment, from exact countsNo fixed strategy wins every query, so each segment chooses, and EXPLAIN shows the choice.
Build the filter, or check it
A filter is either built as a set from its lists or checked row by row, whichever the exact counts say is cheaper.
MeasuredFiltered BM25 3.1 to 4.0× faster than Tantivy's.M2 · results
Vector filters measured near the query
A 32-result probe tells how much of the filter lies near the query, then picks exact scan, IVF, HNSW or post-filter.
Measured2.7× (TREC-COVID) and 6.1× (Quora) faster than the best fixed strategy, recall@10 0.991 to 0.998.M2 · results
Hybrid as one plan
Each input's top 100 under the same filter, rescored exactly by every input, then fused.
Measured0.2 to 0.8 ms, recovering 89 to 95% of the exact fused top 10.M2 · results
Large plans on DataFusion
Search stays on ChloeDB's indexes; joins, groups and windows over more than 4,096 rows run as one Apache DataFusion plan that spills to disk.
MeasuredA join and group over two 100,000-row tables: 60 ms against 285 ms.Xeon VM, 2.10 GHz · engines
Cluster and merges
shards that answer like one databaseA shard is the same file a program opens. Keys hash to 4,096 slots under an epoch, so slots move while the cluster serves.
BM25 scored as one collection
The coordinator sums every shard's term statistics, so each shard scores as the unsplit collection would. It caches them per shard version.
Hedged reads
When a replica is slow, the next is asked too and the first answer wins, with hedges capped to a share of calls.
Merges that stream
Flushes and merges run without the writer lock and stream their output, so memory stays bounded.
MeasuredA 2M-passage merge peaks at 4.0 to 4.1 GB of heap instead of 7.6 GB.Xeon VM, four threads · design
Parallel builds, identical bytes
A segment builds on up to eight threads, byte for byte the same as a one-thread build.
MeasuredA TREC-COVID text segment in 2.9 to 3.2 s on four threads, against 9.0 to 9.7 s on one.Xeon VM · design
Where ChloeDB is behind
- Key lookups through a coordinator. 0.99 ms at 10M, where Postgres, Weaviate, ParadeDB and Qdrant read a row in 0.37 to 0.47 ms (10M). Most of it is the hop from a coordinator to the shard, not the read. At 16 clients ChloeDB serves 12,081 a second with #299, which answers a pod's own shard in process, and OpenSearch 12,285 on the same machines.
- Typo search. The typo walk (#242, then #266's in-memory term table) took the cloud medians from 120 to 11.9 ms at 1M and from 824 to 45.8 ms at 10M; something since 7 November has slowed them to 16.5 and 55.1 ms, and it is not bisected yet. Meilisearch and Typesense take about 7 ms at 1M, and Elasticsearch 32.4 at 10M (10M).
- BM25 under load. At 10M and 16 clients ChloeDB serves 650 queries a second, Elasticsearch 662 and OpenSearch 820, taking turns on the same machines. Moving the coordinators into the shard pods (#287) added 3%: what waits is the shards' own scoring.
- Builds. The HNSW graph is 146 s of Quora's 153.1 s load on an M2.
- Cold filters and small facets. Tantivy is 1.4 to 3.4× faster on cold range filters, and 1.1 to 2.1× on facets in three of four BEIR collections (M2).