strata

Strata: full text, structured filters and vectors in one SQL file

An embedded search database in the spirit of SQLite: one file, ACID transactions, SQL. Every table is indexed three ways at once (posting lists, a columnar forward index and vector ANN indexes), and a cost-based planner combines them in a single query. This page is the design, the prototype built from the earlier posting-list research, and its evaluation against SQLite and Tantivy on four BEIR collections.

Text and filters, warm
1.7–3.2× Tantivy

BM25 top-10, and faster than Tantivy in 24 of 28 text and filter comparisons. FTS5, which scores every match, is 43–200× slower. Tantivy keeps facet counts on three of four collections and stays ahead on cold structured filters.

Vectors
0.05–0.10 ms

HNSW top-10 over 1,024-dimension vectors, with recall@10 0.99 on Quora. SQLite's scan takes 7.7 ms to 0.7 s. Cold, a graph walk reads about 4,000 pages where the scan reads all of them.

Hybrid in one statement
+0.02–0.04 nDCG

Weighted fusion of BM25 and vectors over vectors alone, on three of four collections, at 0.2–0.8 ms. RRF matches SQLite's RRF over the same rankings to within 0.005.

Filtered vector planner
1.8–6.1× faster

Faster than the best fixed strategy on the three larger collections, and within 1.0–1.6× of a per-query oracle. On SciFact, always pre-filtering takes 17% less time.

What it does

One file, one SQL statement, three kinds of index: the planner decides per segment which index drives the query and how the others constrain it.

SQLite answers full-text queries with FTS5 and structured ones with B-trees, but it has no vector index, and its FTS5 scores every match without pruning. Search libraries such as Tantivy rank text quickly but have no SQL, no vectors and no transactions. Vector databases do the opposite. Strata keeps SQLite's packaging (an embedded library, one file, a write-ahead log, snapshot isolation) and puts a search engine inside it.

-- full text, ranked, with structured filters
SELECT id, title, score() FROM docs
WHERE MATCH(body, 'vaccine AND (mrna OR "messenger rna") -animal')
  AND year BETWEEN 2019 AND 2021 AND category IN ('c01', 'c02')
ORDER BY bm25(body, 'mrna vaccine efficacy') DESC LIMIT 10;

-- filtered vector search
SELECT id FROM docs WHERE rating >= 4 ORDER BY similarity(emb, :q) DESC LIMIT 10;

-- hybrid ranking: rank fusion, or a weighted sum of normalised scores
SELECT id FROM docs WHERE year >= 2015
ORDER BY 0.2 * bm25(body, :text) + 0.8 * similarity(emb, :q) DESC LIMIT 10;

-- facets over any result
SELECT category, COUNT(*) FROM docs WHERE MATCH(body, 'vaccine')
GROUP BY category ORDER BY 2 DESC LIMIT 5;

The dialect is plain SQL parsed by sqlparser. Search functions are MATCH (boolean full text with phrases, prefixes and negation, juxtaposition meaning AND as in FTS5), bm25, similarity and distance, and rrf, with named options such as nprobe => 32 or strategy => 'prefilter'. Text fields can be generated from other fields, like SQLite's GENERATED ALWAYS AS, so the searchable body (title and text) is indexed without being stored twice.

StrataSQLite + FTS5Tantivy
Embedded, one file, ACIDyesyesdirectory of segment files
SQLyes (SELECT)yesno
BM25 top-k with pruningMaxScore, Block-Max WANDscores every matchBlock-WAND
Structured filterscolumns, range and keyword postingsB-tree indexesfast fields, range queries
Vector searchflat, IVF, HNSW, filteredbrute force via a functionnone
Hybrid ranking in one queryyesapplication sideno

Architecture

Strata is layered like SQLite, with a search engine where SQLite keeps its B-tree module. SQL text is parsed and bound to the table's schema, giving a predicate tree (text matches, ranges, IN lists under AND, OR and NOT) and a score expression (BM25, similarity, fusion or a column). The planner decides per segment, from statistics the indexes answer without scanning, how each part is evaluated. Operators run on zero-copy views of the segment's sections, mapped straight from the file.

Layers. Every index structure lives in immutable segments. A segment is a directory of named, aligned sections that operators read in place through one memory mapping of the file, so opening a database reads two pages and a manifest, however large it is.

Storage

SQLite updates B-tree pages in place. Compressed posting lists, bit-packed columns and ANN graphs do not survive in-place updates: the best encodings, such as partitioned Elias-Fano, are chosen per list, and changing one docID means re-encoding the list. SQLite's own FTS5, Lucene and Tantivy all keep their indexes as immutable segments merged in the background. Strata does the same for the whole table and adds SQLite's transactional envelope.

One file plus a WAL. Two meta slots name the current manifest. A commit writes new extents, syncs, then flips to the other slot and syncs again. Small transactions go to the write-ahead log and an in-memory memtable first, and are flushed into a segment when the memtable fills.

Commit and recovery

The commit protocol is shadow paging, as in LMDB: nothing reachable from a valid meta slot is ever overwritten, so there is no rollback journal.

\[ \text{commit}_{t+1}:\ \text{write extents} \;\to\; \text{fsync} \;\to\; \text{write slot } (t+1) \bmod 2 \;\to\; \text{fsync}, \qquad \text{recover} = \operatorname*{arg\,max}_{s \in \{A, B\},\ \text{crc}(s)\ \text{ok}} \text{txn}(s). \]

A torn slot fails its checksum and recovery falls back to the other one, which still names a complete version. Freed pages wait until no snapshot needs them, plus one extra commit, so the older slot always stays valid. A crash test kills a writer process with SIGKILL at random moments, over and over; after every restart the database equals some committed prefix of the writes.

Writes, snapshots and merges

Indexes

Every field type maps to the structures that serve it. The posting-list study that preceded this design chose the encodings: Loom for ranked text, Pyramid for filter lists, BP128 for short lists.

One row, three index families. All of them are built once per segment from documents in docID order and read in place.

Full text

The analyzer splits on non-alphanumeric characters, lowercases, folds accents, drops 33 stopwords and applies the Snowball English stemmer. Ranked queries also drop NLTK's 153 English function words and count each term once. Terms sit in front-coded dictionary blocks of 32. Lists of at least 512 documents keep their docIDs as Loom, with frequencies bit-packed per 128 postings and addressed by posting rank; shorter lists use BP128 blocks. Document lengths are one-byte norms. Ranking is BM25 with collection-wide statistics summed over the snapshot's segments, so a document scores the same in any segment:

\[ \mathrm{BM25}(d, q) = \sum_{t \in q} \ln\Bigl(1 + \frac{N - n_t + 0.5}{n_t + 0.5}\Bigr) \cdot \frac{f_{t,d}\,(k_1 + 1)}{f_{t,d} + k_1\bigl(1 - b + b\,\frac{|d|}{\overline{|d|}}\bigr)}, \qquad k_1 = 1.2,\ b = 0.75. \]

Top-k uses MaxScore by default: terms are sorted by their upper bound \(U_t\), and once the threshold \(\theta\) of the current top-k exceeds the sum of the smaller bounds, those lists stop driving iteration and are only probed. Block-Max WAND is available, but on these collections' queries MaxScore measured 1.9–2.6× faster. A filter either drives scoring, when it is small enough that scoring its members directly is cheaper, or is probed per candidate. The crossover is a fitted constant times the filter size against the query's list lengths.

Structured fields

Vectors

Each vector field keeps float32 vectors for exact re-ranking and 8-bit codes for scanning. Codes are per-dimension scalar quantised, and the query is quantised too, so the inner loop is an integer dot product: NEON usdot on aarch64 (16 byte products per instruction), AVX-512 VNNI on x86-64:

\[ c_i = \Bigl\lfloor \frac{x_i - \min_i}{\Delta_i} \Bigr\rceil, \qquad \langle q, \hat{x} \rangle = \sum_i q_i (\min_i + \Delta_i c_i) \;\approx\; \alpha \sum_i \tilde{q}_i\, c_i + \beta, \]

with \(\tilde q\) the 8-bit query, \(\alpha, \beta\) per-query constants, and one 1,024-dimension score in 10–14 ns on the M2. Three index kinds sit on top. Flat scans codes and re-ranks the best \(r\) in float32. IVF stores each k-means cluster's docIDs contiguously, followed by their codes, so a probe is one sequential read and a filter is an intersection with the cluster's docID list. HNSW keeps fixed-degree adjacency arrays in the segment; filtered HNSW traverses through non-matching nodes but only collects matching ones.

Planner

The planner works per segment from statistics the indexes answer in microseconds: exact list lengths for terms and keyword values, histogram counts for ranges, document counts, and the vector index's calibrated cost model. Conjunctions assume independence and disjunctions use inclusion-exclusion:

\[ \hat s(P_1 \wedge P_2) = \hat s(P_1)\,\hat s(P_2), \qquad \hat s(P_1 \vee P_2) = 1 - (1 - \hat s(P_1))(1 - \hat s(P_2)), \qquad \hat s(\neg P) = 1 - \hat s(P). \]

Materialise or probe

A predicate is either evaluated into a document set before ranking, or checked per candidate of the ranking operator. If that operator tests \(m\) candidates, it materialises when

\[ C_{\text{mat}}(P) < m \cdot c_{\text{probe}}(P), \qquad c_{\text{probe}}(P_1 \wedge \dots \wedge P_k) = \sum_{i=1}^{k} c_i \prod_{j < i} \hat s_j \quad (\hat s_1 \le \hat s_2 \le \dots), \]

so a conjunction is probed most selective leaf first, short-circuiting. Inside a materialised conjunction the same test applies child by child: once the running result is small, each remaining child is probed per survivor instead of materialised.

Filtered vector search

Four strategies compete. Pre-filter scans the filter's members exactly. In-index searches IVF or HNSW with the filter applied inside. Post-filter searches unfiltered with \(k' \approx k/s\) and drops non-members. Flat scans everything. Their costs, from the vector index's model, are roughly

\[ C_{\text{pre}} \approx C_{\text{mat}} + s\,n\,c_{\text{sq8}}, \qquad C_{\text{HNSW}} \approx \frac{\text{ef}\cdot M\,c_{\text{dist}}}{s_{\text{near}}}, \qquad C_{\text{IVF}} \approx \frac{\text{nprobe}}{\sqrt{s_{\text{near}}}}\cdot\frac{n}{n_{\text{list}}}\,c_{\text{sq8}}, \qquad C_{\text{post}} \approx C_{\text{index}}\Bigl(\frac{k}{\min(s, s_{\text{near}})}\Bigr). \]

The index strategies pay for the selectivity near the query, \(s_{\text{near}}\), not the global \(s\). A filter on a topic far from the query has almost no members among the query's neighbours, so HNSW wanders through thousands of nodes. When the global estimate favours an index strategy, the planner measures \(s_{\text{near}}\) with a 32-result unfiltered search and re-plans:

\[ \hat s_{\text{near}} = \frac{\bigl|\{\, d \in \mathrm{NN}_{32}(q) : P(d) \,\}\bigr| + \tfrac12}{32 + 1}. \]
A filtered hybrid query. Each input retrieves its top 100 under the same filter, here probed per candidate because both drivers test few documents. The union is re-scored exactly by both inputs, min-max normalised and summed. RRF fuses ranks instead, using the same retrieval.

Hybrid ranking

Reciprocal rank fusion and weighted fusion are both one SQL expression:

\[ \mathrm{RRF}(d) = \sum_{i} \frac{1}{60 + \mathrm{rank}_i(d)}, \qquad \mathrm{W}(d) = \sum_i w_i\, \frac{s_i(d) - \min_{C} s_i}{\max_{C} s_i - \min_{C} s_i}, \]

where \(C\) is the union of each input's top 100. With exact => 1, \(C\) is every row passing the filter, which gives the reference ranking for measuring how much the top-100 shortcut loses.

Evaluation

Four BEIR collections, with Cohere embed-english-v3 vectors (1,024 dimensions) for documents and queries, and human relevance judgments: SciFact (5,183 documents), FiQA (57,638), TREC-COVID (171,332) and Quora (522,931). Each document also has synthetic structured fields: year uniform over 1990–2024, category Zipf-distributed over 64 values, rating uniform over [0, 5). A content-correlated topic (the k-means cluster of the document's vector) gives filters that correlate with queries. One generated workload per collection is run by all three systems: BM25, boolean, filter, vector, hybrid and facet queries, at filter selectivities from 0.1% to 50%.

Each system is fully built (one Strata segment, one Tantivy segment after merging, one SQLite file), then measured single-threaded on an Apple M2 MacBook Air (NEON kernels, on mains power), nothing else running. Warm latency is the median of up to three repetitions per query. Cold runs close the database, evict its files from the OS page cache, reopen and run one query; pages read are the file pages the query brought into the page cache.

Build time and size

Strata builds every index of the table in one pass: text, structured, doc store, keys, float32 and 8-bit vectors, and an HNSW graph. That takes 0.5 s for SciFact and 153.1 s for Quora, against 0.3–30.7 s for SQLite and 0.4–9.3 s for Tantivy. Neither baseline builds a vector index: SQLite keeps the vectors as blobs and scans them, and Tantivy has none.

The graph is most of the difference. It takes 12.9 s of FiQA's 14.2 s, 37 s of TREC-COVID's 40.6 s and 146 s of Quora's 153.1 s, on four threads. The rest of the load takes 1.3–7.5 s, 0.2–0.5× SQLite's time. With IVF instead of HNSW, TREC-COVID builds in 19.2 s and Quora in 60.1 s.

The Strata and SQLite files are close in size because both are dominated by float32 vectors, 4 KiB per document. Vectors are 83% of Strata's TREC-COVID file and 97% of Quora's. That share covers the float32 copy kept for re-ranking, 1 KiB of 8-bit codes per document, and 128 bytes of graph. Tantivy, which stores no vectors, takes 7–180 MiB.

Without vectors, Strata's text index is the smallest of the three. With positions, it takes 44.5 MiB on TREC-COVID, against 60.0 MiB for Tantivy and 70.0 MiB for FTS5. On Quora it takes 11.8 MiB, against 21.1 and 25.3 MiB. Part of that gap is the 33 stopwords Strata drops at index time, which the baselines keep. A posting, with its docID and frequency, costs 12.2–12.7 bits. The structured index (columns, keyword postings and range buckets) takes 4.5 MiB on TREC-COVID, against 8.4 MiB for SQLite's four B-tree indexes and 2.7 MiB for Tantivy's columns. The doc store is within 16% of Tantivy's; both use LZ4.

Query latency

Warm, Strata is faster than Tantivy in 24 of the 28 text and filter comparisons:

  • BM25 top-10: 1.7–3.2× faster than Tantivy, and 43–200× faster than FTS5, which scores every match.
  • Two-term conjunctions: 2.7–4.1× faster than Tantivy.
  • Filtered BM25: 3.1–4.0× faster than Tantivy.
  • Vector top-10: 0.05–0.10 ms with HNSW. SQLite's scan takes 7.7 ms on SciFact and 0.7 s on Quora.
  • Hybrid queries: 0.17–0.77 ms. They run BM25 and the vector index, then fuse their top 100s.

Median latency by query kind

The same workload in each system · Tantivy has no vector search · SQLite answers vectors by a brute-force scan

The exceptions are facet counts on SciFact, FiQA and Quora, where Tantivy is 1.1–2.1× faster (on TREC-COVID Strata is 1.5× faster), and SciFact's three-term conjunctions. These queries take 9–27 µs in Tantivy. At that size, the fixed cost of a SQL statement shows: even a query that matches nothing is parsed, bound, planned and run. Strata also materialises the match before reading category codes, while Tantivy's collector reads its column inside the intersection.

Cold, every system waits on page faults and the gaps narrow:

  • Text queries: Strata is within 0.5–1.5× of Tantivy. On BM25 it is faster on SciFact (1.6 against 2.1 ms) and TREC-COVID (6.6 against 7.2 ms), and 12–38% slower on Quora and FiQA.
  • Structured filters: Strata is 1.4–3.4× slower than Tantivy's columns. A range touches histogram buckets, boundary blocks, zone maps and the key index, each on different pages.
  • Vectors against SQLite: a cold vector query is 28–63× faster on the two large collections. HNSW touches about 3,700–4,400 pages, where the scan reads all 239,000 or 592,000. On SciFact, a cold scan of SQLite's 20 MiB of vectors is faster than a cold graph walk (30 against 39 ms).

Page counts are in 4 KiB units, but macOS pages are 16 KiB: a random fault reads four times the data of a 4 KiB page, so random-access queries such as HNSW read more, and are slower cold, than on the Xeon VM these runs replace.

Cold reads and page-cache hints

Cold latency depends on what the kernel reads around each page fault, and the right policy differs by section. The table compares three policies on the two large collections:

  • Read-ahead everywhere (the kernel's default). A cold HNSW query reads 7,364 pages on TREC-COVID and takes 117 ms: twice the pages it reads when the graph is advised random access.
  • No read-ahead (MADV_RANDOM on the whole file). Vector queries drop to 3,676 pages on TREC-COVID and 4,416 on Quora, and take 102–115 ms. BM25, facets and filters, which read postings and columns in order, then fault page by page and are up to 1.5× slower than with read-ahead.
  • Default hints. Random access is advised only for sections read at random: the doc store, the key index, term dictionaries, float32 vectors, and the graph with its codes. Postings, norms, columns and IVF lists keep read-ahead. Vector and hybrid queries stay at the random-access cost, and BM25 is 0.8–1.0× its read-ahead time.

Structured filters are the exception: under the default hints they are 1.2–1.5× slower than with read-ahead everywhere. These queries sort by rating and break ties by key. With 500 rating values, a permissive filter leaves hundreds of documents tied at the top. Their keys are scattered over the key index, so each one costs a separate fault. Keeping read-ahead on the docID-to-key half of that index would remove the cost. Per-section hints are a first step; the planner knows each query's access pattern and could choose them per query.

Median milliseconds per query after evicting the database from the page cache, and the median number of 4 KiB pages read (macOS faults in 16 KiB pages, four of these units). Highlighted: the fastest policy for each kind.

Ranking quality

Strata's BM25 is within 0.018 nDCG@10 of both baselines on every collection, and no system is consistently ahead: Strata leads on SciFact, Tantivy on TREC-COVID, FTS5 on FiQA and Quora. The analysers differ. Strata stems with Snowball and drops stopwords, FTS5 uses the Porter stemmer, and Tantivy uses Snowball and keeps stopwords.

HNSW is within 0.006 of the exact scan on three collections. SQLite ran only 300 of Quora's 2,000 vector and hybrid queries, so the Quora row compares different query sets. On the shared 300, HNSW scores 0.867 against 0.880 exact, with recall@10 0.989; four queries that lost a relevant duplicate account for the whole difference. Strata's RRF is within 0.005 of SQLite's RRF over the same two rankings, also on those 300 Quora queries (0.846 against 0.850).

All three systems drop NLTK's 153 English function words from BM25 queries, so the rankings are comparable; bm25(body, :text, stopwords => 0) keeps them. On the same queries, dropping them gains 0.055 nDCG@10 on TREC-COVID, whose queries are full questions, and 0.002 on SciFact and FiQA. It costs Quora 0.055 (0.756 against 0.811): its questions are short, and "how", "why" or "can" carry much of their meaning.

Quora: SQLite's exact vector and RRF columns cover 300 queries, Strata's 2,000. On the same 300, Strata scores 0.867 (HNSW) and 0.846 (RRF).

Weighted hybrid ranking: nDCG@10 by BM25 weight

Scores min-max normalised over the union of each input's top 100 · 0 = vectors only, 1 = BM25 only

Weighted fusion beats both of its inputs on three of the four collections. The best BM25 weight is small, 0.1–0.3: the scales differ, and on these collections the embeddings are the stronger ranking. On TREC-COVID it reaches nDCG@10 0.851, against 0.815 for vectors alone, 0.835 for RRF and 0.658 for BM25. On Quora it reaches 0.920 against 0.899 and 0.860. On FiQA, where BM25 is weak (0.268), fusion only matches the vector ranking (0.437), and RRF falls below it (0.381), because RRF gives both rankings equal weight.

The top-100 shortcut is cheap and close to exact. Against weighted ranking computed over every document, it recovers 89–95% of the exact top-10, and its nDCG@10 is within 0.01–0.03. It costs 0.2–0.8 ms per query, where the exact computation costs 0.9 ms on SciFact, 12 ms on FiQA and 62 ms on TREC-COVID.

Posting formats and top-k

The text index stores long lists (at least 512 documents) as Loom, the aligned partitioned Elias-Fano design from the posting-list study, and short lists as BP128 blocks. The table compares that against BP128 for every list, on the same index:

  • Conjunctions are where Loom pays off. AND is 7.6–11× faster (7.5 against 57 µs on FiQA, 21 against 230 µs on TREC-COVID): Loom's cursors skip with sampled pointers instead of decoding whole blocks. OR gains nothing: the two formats are within 2% of each other on TREC-COVID and Quora, and Loom is 1.2× slower on FiQA.
  • Size is 2–4% smaller than BP128, at 11.7–12.7 bits per posting including frequencies.
  • Ranked top-10 is close: MaxScore is within 0.95–1.0× across formats. MaxScore beats Block-Max WAND by 1.9–2.6× on these queries.

Mean microseconds per query, warm cache, one thread. Bits per posting cover docIDs, frequencies and list metadata.

Vector indexes

On Quora (522,931 vectors, 1,024 dimensions), HNSW reaches recall@10 0.960 at 0.036 ms and 0.990 at 0.086 ms (ef 64, the default). IVF needs 0.22 ms for 0.936 (nprobe 32) and 0.67 ms for 0.977. The exact scan of 8-bit codes with float32 re-ranking reaches 1.000 in 9.7 ms.

The quantised dot product costs 14 ns per vector with NEON usdot (9.8 ns when four rows are scored at once), against 70 ns in float32; on x86-64 the same kernel uses AVX-512 VNNI. Scoring on the codes alone already finds 99.8% of the exact top-10 over 100 sampled queries; float32 re-ranking settles the rest. HNSW took 146 s to build with four threads, IVF 53 s.

Cold, access patterns decide. With the kernel's default read-ahead, one HNSW query reads 9,672 pages (136 ms). Advising the graph and its codes MADV_RANDOM cuts that to 4,836 pages (113 ms), and prefetching each hop's neighbours cuts it to 28 ms. IVF reads its clusters sequentially, so it is fastest with read-ahead: 26 ms, or 10 ms with prefetching.

Recall@10 against latency

Warm cache · each point is one setting of ef, nprobe or re-rank depth

Filtered vector search and the planner

Filtered vector search is where one fixed strategy cannot win. The chart shows mean latency per strategy at each filter selectivity on the workload's filters:

  • Pre-filtered scan: its cost grows with the number of matching documents.
  • HNSW with the filter inside: cheap for permissive filters, but very expensive for selective ones, and for filters whose matches sit far from the query.
  • Post-filtering: sensitive to both.

The filters include random ones and topic filters drawn near to and far from the query.

Filtered vector search: time by strategy and selectivity

Mean over the workload's filters at each selectivity (random and topic filters, near and far from the query)

Across 300 filtered vector queries per collection, the planner is 2.7× faster than the best fixed strategy on TREC-COVID (121 ms against 325 ms for always pre-filtering) and 6.1× faster on Quora (179 ms against 1,089 ms). Recall@10 stays at 0.991–0.998. Always using the HNSW index would take 2.9–6.1 s. Against an oracle that knows the fastest plan per query with recall ≥ 0.9, the planner's total time is 1.0–1.6× the oracle's.

Two refinements made that gap small; the timings in this paragraph come from the development runs on the earlier Xeon VM. The first measures selectivity near the query. Planning on global selectivity alone, 100 TREC-COVID queries took 328 ms against an oracle's 48 ms. A 32-neighbour sample brought that to 61 ms. On Quora, though, it still sent far-topic 10% filters into 60–100 ms graph walks where a 5 ms scan sufficed: 1,076 ms in total. A second, 160-neighbour sample, taken when the first finds at most one match, brought Quora to 451 ms. The second refinement costs post-filtering with the smaller of the global and local selectivity, since its candidate pool is sized from the global one.

For BM25 with filters, and for structured filters alone, geometric-mean regret is 1.06–1.18. Range filters choose between a zone-map scan and histogram bucket postings, and filtered BM25 chooses between driving scoring from the filter and probing it. On IVF, the planner leans on the index and gets recall 0.93; an oracle limited to recall ≥ 0.9 must spend more, which is why the IVF rows show the planner faster than that oracle.

Compound queries

The workload measures one query shape at a time. These ten statements combine them: phrases with negation, prefixes, OR and NOT filters, both fusion methods, facets over a match, column ordering, and exact distance with a forced strategy. Each runs on every collection with the first test query's text and vector bound to :t and :q. Each cell shows the median time, the row count and the plan, read from the executor's plan lines.

The same statement gets different plans as the data changes. The OR filter in the fourth query matches about 15% of documents everywhere. On SciFact the planner scans those 800 documents. On the larger collections it measures 11% near the query and post-filters the HNSW result. The RRF query's topic filter matches 11% of Quora globally but only 3.4% near this query, so the planner switches to an exact scan of the 58,767 members, at 3.1 ms.

Transactions and storage

A durable single-document commit is one WAL append and one fsync: 4.1 ms at the median, 227 commits per second. On macOS the sync is F_FULLFSYNC, which makes the SSD flush its write cache; the earlier VM's fdatasync on a virtual disk did not have to, and took 0.27 ms. Batching amortises the sync. With 1,000 documents per transaction, the WAL takes 98,000 documents per second. Without fsync it takes 155,000–438,000; a process crash still loses nothing then, but a power failure may lose recent commits.

Write throughput through the WAL

FiQA documents, one writer · each transaction commits

  • Read your writes. Committed documents are searchable at once. The first query after a write rebuilds the memtable's last 1,024-document chunk with every index of the evaluation table, which takes 17–20 ms. An unchunked memtable of 10,000 documents takes 169 ms. Later queries reuse the chunk, and taking a snapshot costs at most 0.13 µs.
  • Opening a database reads the meta slots, the manifest and each segment's directory. Cold, that takes 6.8 ms for 10 segments, 40 ms for 100 and 279 ms for 994 (6 ms warm). Replaying 10,000 WAL documents takes 34 ms at open, plus 207 ms to index them at the first query.
  • Merges. A tiered merge of eight 5,000-document segments, 10% of them deleted, rebuilds every index in 0.75 s, about 48,000 documents per second. After a delete-heavy workload the file is 1.22× its compacted size until vacuum.
  • Recovery. The crash test kills a writer process with SIGKILL at a random moment during inserts, deletes, commits and flushes, then reopens. Every restart recovered a committed prefix: 20 runs by default, and 60 and 80 in longer runs. A damaged meta slot falls back to the other one.

Verdict

The design holds up. One file, with ACID commits and a SQL front end, serves full text, structured filters, vectors and their combinations. Warm, it is faster than both specialised baselines on most of the workload, and its quality matches theirs. It pays for that in build time and in cold structured filters.

One embedded file for three index families

Met: every query of the workload, and the ten compound statements, runs as SQL against one file. Commits are durable at 4.1 ms, nearly all of it macOS's F_FULLFSYNC, which flushes the drive's write cache. Every crash test recovered a committed prefix. Snapshots cost at most 0.13 µs, and the file is near SQLite's size.

Missed: SQL covers single-table SELECT only; writes go through the Rust API. Building the HNSW graph makes loads 1.7–5.9× slower than SQLite's (0.2–0.5× without it).

Faster than the specialised engines

Met: warm BM25 is 1.7–3.2× faster than Tantivy, and conjunctions 2.7–4.1× faster. Strata wins 24 of 28 warm text and filter comparisons. Vector queries take 0.05–0.10 ms, against SQLite's 7.7 ms to 0.7 s scans, and are 28–63× faster cold.

Missed: Tantivy counts facets 1.1–2.1× faster on three of the four collections. Cold structured filters are 1.4–3.4× slower than Tantivy's, because a range touches several sections and key tie-breaks fault one page per key.

Hybrid ranking as one plan

Met: RRF and weighted fusion are single SQL expressions, under the same filter as their inputs. RRF quality equals SQLite's RRF. Weighted fusion adds 0.02–0.04 nDCG@10 over vectors alone on three collections, at 0.2–0.8 ms.

Missed: the top-100 shortcut recovers 89–95% of the exact fused top-10. The best weight differs by collection (0.1–0.3), and nothing picks it automatically.

A planner that adapts per query

Met: for filtered vector search, the planner is 1.8–6.1× faster than the best fixed strategy on the three larger collections, with recall@10 0.991–0.998. For filtered BM25 and filters alone, geometric-mean regret is 1.06–1.18.

Missed: it spends 1.0–1.6× an oracle's time. On SciFact, always pre-filtering takes 17% less time. With 5,183 documents, scanning a filter's members is never expensive, and planning, probing and the occasional index plan add 1–29 µs per query.

Where it fits

Limitations

Next steps

Reproduce

cd strata
python3 scripts/prepare_beir.py /home/user/data/beir   # BEIR + embeddings (≈ 4.8 GB)
cargo test --release                                   # every component, end-to-end SQL test
scripts/run_eval.sh                                    # all experiments, sequentially (≈ 4 h)
python3 scripts/build_report.py                        # this page