#1013·qmd

Search at scale: open performance fixes, where they overlap, and a merge order (with and without an index migration)

Author: brettdaviesCreated Sep 29, 2026Updated Sep 29, 2026

[!NOTE] AI disclosure: an AI agent (Claude) surveyed the open PRs, ran the benchmarks and wrote the analysis and summaries in this issue; I reviewed and approved it before posting. It's written for both human and AI readers.

Bottom line

  • qmd's cost grows with the whole index rather than with the collections being searched, at several stages of a query. On an 804k-vector index with 13 collections searched by default, a qmd query on main takes about 2.5 minutes (median of six queries, model time included), and a search process peaks at 1.4 GB. #952 has two independent reports of the same shape.
  • About 20 open PRs address parts of it. Several are alternatives to each other, none has a maintainer review yet, and CI hasn't run on most of them because they come from first-time contributors.
  • Recommended: merge the small, independent fixes first (#1009, #953, #1000); then one vector-scoping fix, either #983 (index migration, fastest) or #936 (no migration), both of which leave result quality unchanged; then split #962 to take its memory and re-index work without its default-path shortcuts, which measurably lower result quality (#1012).
  • Disclosure: I wrote #936, #983, #937 and #927. The measurements below come from the same index copy and harness for every build, and the harness is published in #1012.

Recommended merge order

  1. Independent and small: #953 (the #918 design, with filter coverage), #1009 (with #946's measurements behind it), #1000, #815, #978, #995 (reconciled with #993) and #923. Each fixes one stage and none needs a migration.
  2. Vector scoping, one of two paths:
    • With a migration: #983. Fastest scoped search, and it already hydrates bodies after the limit, so #932 isn't needed. Then #937 with its partition-aware follow-up.
    • Without a migration: #936, plus #932 for body memory and #937 as is. #952's measurements suggest a per-key lookup for small collections on very large tables as a follow-up.
  3. #962, split. Take the re-index fast path (which makes #504 unnecessary), the streaming .iterate() changes and the memory bounds. Hold the keyword shortcut, the rerank-off default, top-3 chunk scoring and the centroid until they're reworked and re-measured: together they drop query nDCG@10 from 0.85 to 0.52 (#1012).
  4. Then measure what's left: keyword-search latency on large scopes with #953 in, #913's expansion caps, and #927 for setups with many concurrent processes.

I'm happy to run any merge order through the same harness, for latency, memory and result quality, before it lands.

Where the time and memory go: each stage, its evidence and its PRs
Stage What scales badly Evidence Open PRs
Collection-scoped vector search Every query reads the whole vector table, however small the scope #952: vsearch 70 s on an 11k-vector collection; vector stage 137.7 s on a 1.38M-vector index. Here: 141 s on the 13-collection scope #936 or #983 (alternatives)
Collection-scoped keyword search BM25 matches the whole index, truncates, then filters by collection: false-empty scoped results (#922) and cost Here: one keyword search takes ~27 s for natural-language queries on the 13-collection scope. #918 reports 507.7 s → 2.0 s across 19 collections #953 or #918 (alternatives)
Fusion across collections One ranked list per collection, so ranking depends on collection order #946: P@1 0.000 → 0.500, MRR 0.279 → 0.607 over 21 collections. #1009: 0 of 50 expected pages found across 11 named collections #1009 or #946 (alternatives)
Query expansion fanout Duplicate expansions each cost an embedding and a vector scan #921: one HyDE string cached 12 times at 10 to 15 s per call. #952: 31 expansions, 9 distinct #1000 or #913 (overlapping)
Document bodies in memory Full bodies loaded per matching chunk #932: vsearch 46.4 GB peak → 1.6 GB. #962: heap 4.2 GB. Here: 1,404 MB peak on main #932, #962 (part), #983 (already hydrates after the limit)
qmd doctor sampling Queries group by full document bodies #978: > 40 GB RSS → 1.54 GB #978, #995
Re-indexing unchanged files Every file is read and hashed on every update #962 reports "minutes" → "seconds" on an unchanged collection #962 (part) or #504 (alternatives)
Dead vector rows Rows of inactive documents stay in the vector table #952: 52,877 vector rows for 11,446 live vectors #937
Per-process overhead Concurrent processes each load models; MCP instructions rebuilt per request; a second runtime spawn #942; #815: "multi-second to tens-of-seconds" initializes on an 83.5k-row index; #923: 223 → 167 ms (Node), 626 → 322 ms (Bun), Windows #927, #815, #923
Measured on one index: latency, memory and result quality per build

Same index copy, same fixed model output, every build (harness and method in #1012; latency from the benchmark on #962).

main #936 #983 #962 #962 + #983
Vector stage, 13-collection scope (median) 141 s 3.9 s 0.26 s 35 s 0.07 s
query end to end, all scopes (median / max) 31 s / 184 s 11 s / 48 s 8.0 s / 43 s 6.5 s / 181 s 3.0 s / 28 s
Peak RSS 1,404 MB 646 MB 503 MB 264 MB 280 MB
query nDCG@10 (19 queries, blind judges) 0.845 0.844 0.844 0.525 0.512
One-time index migration 191 s for 804k vectors 191 s

#952 has an independent run of the same builds on a 1.38M-vector index: vector stage 137.7 s on main, 7.2 s on #936, 0.1 s on #983, with the same top 10 across all of them, and a 384 s migration.

Overlap: alternatives, complements and conflicts

Alternatives: pick one of each pair.

  • #983 or #936 (vector scoping). #983 partitions the vector table by collection, so a scoped search reads only its own collection; it needs a one-time migration. #936 keeps the schema and pre-filters the KNN, which still reads the whole table once per query (3.9 s against 0.26 s above). Result quality is the same for both.
  • #918 or #953 (keyword scoping). The same design: materialize the match set and filter by collection before the limit. #918 carries the large-index measurements and the query-plan analysis; #953 extends it to metadata filters, which main added after #918 was written, and credits #918.
  • #946 or #1009 (fusion across collections). The same change. #946 carries the ranking measurements; #1009 adds a test and passes through the metadata-filter argument that structuredSearch now takes.
  • #1000 or #913 (expansion fanout). #1000 drops exact duplicates. #913 is the fuller policy (case-insensitive deduplication, at most six variants and two per type, and no restatements of the query) plus cancellation, but it depends on #912's shutdown changes, and its caps change fused rankings in ways nobody has measured.
  • #962's re-index fast path or #504. #962's runs inside qmd update and checks size as well as mtime; #504 adds a separate qmd collection sync command and a column, checks mtime only, and adds rename detection.
  • #932, #962's body cap, or #983. All three stop loading a full body per chunk. #932 keeps output identical; #962 truncates bodies to 256 KB; #983 already reads bodies only for the final results.

Complementary. Fewer scans (#1000) stack with cheaper scans (#936 or #983). #953 and #1009 fix the two halves of keyword retrieval across collections. #937 applies to either vector path.

Conflicts. On current heads, git merge-tree finds code conflicts only between #936, #983 and #962 (all in searchVec); other pairs collide only in CHANGELOG.md or one test file. Four conflicts don't show up as text:

  • #962's centroid reads stored vectors from vectors_vec, which #983 replaces; merged naively, it falls back to re-embedding without an error.
  • #937's repack walks the legacy vector table and needs its partition-aware follow-up if #983 lands first.
  • #993 and #995 rewrite the same qmd doctor sampling query in different directions.
  • #913 adds cancellation checks inside the per-collection loop that #946 and #1009 delete.
PR inventory (state on 2026-09-28)
PR Author Stage Depends on CI Schema change Evidence in the PR
#504 kiranshivaraju Re-index none none disk_mtime column tests, no timings
#815 fxstein MCP startup none passed no "multi-second to tens-of-seconds"
#913 rszrszrsz Expansion fanout, cancellation #912 (draft) failed (no jobs ran) no tests, no timings
#918 fxstein Keyword scoping written before metadata filters; #953 extends it full matrix passed no 507.7 s → 2.0 s over 19 collections
#923 ilepn CLI startup overlaps #912's spawn rewrite passed no Windows medians
#927 brettdavies Shared model server none passed no combines #662 (low-VRAM engine) and #663 (qmd serve)
#932 mendelcyprys Body memory written before the metadata-filter join not run (needs approval) no 46.4 GB → 1.6 GB peak
#933 naveenspark Result dedupe by content none not run (needs approval) no one test
#936 brettdavies Vector scoping (no migration) none full matrix passed no measured on 800k-vector index
#937 brettdavies Dead vector rows partition-aware follow-up if #983 lands full matrix passed no measured on 800k-vector index
#946 shalom-t Fusion across collections written before structuredSearch's filter argument not run (needs approval) no P@1 0.000 → 0.500 over 21 collections
#953 Mr-Beasley Keyword scoping none not run (needs approval) no small-corpus timings, tests
#962 rikvanriel Memory, re-index, default path none not run (needs approval) file_sync_state table "54s/71s to 0.5-1.5s", "1.44GB to 164MB"
#978 naveenspark qmd doctor memory none not run (needs approval) no > 40 GB → 1.54 GB RSS
#983 brettdavies Vector scoping (migration) none full matrix passed partitioned vector table measured on 800k-vector index
#995 mjaverto qmd doctor memory rewrites the same query as #993 not run (needs approval) no tests under a 128 MiB heap cap
#1000 ParkerRex Expansion fanout none not run (needs approval) no 15 expansions → 3, test
#1009 xidus90 Fusion across collections none not run (needs approval) no 0 → 31 of 50 pages, test