Lance semantic index grows to 140 GB for 657 MB of vectors (one commit per row, full manifest per commit, no compaction)
Summary
On a long-running install, the Lance semantic index grew to 139.95 GB while the actual vector data was only 657 MB. The _versions/ directory contained 64,611 manifests (138.79 GB) and data/ contained 64,609 fragments (1.11 GB) for 42,059 vectors. The store had 52,819 observations across 6 projects.
The cause is three behaviors compounding: one Lance commit per observation, a full manifest written on every commit, and no compaction/cleanup. A cold-start path that re-embeds vectors missing from the in-memory cache amplifies it by tens of thousands of commits per restart.
What I observed
~/.memorix/data/semantic-index/observations_<hash>.lance:
| Path | Size | Files |
|---|---|---|
_versions/*.manifest |
138.79 GB | 64,611 |
data/*.lance (fragments) |
1.11 GB | 64,609 |
| index (IvfHnswSq) | ~180 MB | — |
The average fragment is ~18 KB and holds one row, so 64,609 fragments ≈ 64,609 single-row writes. The latest manifest was 3.59 MB and referenced 41,778 live fragments.
Growth timeline (manifest bytes / manifest count):
| Date | Size | Manifests |
|---|---|---|
| 2026-09-11 | 0.07 GB | 1,328 |
| 2026-10-08 | 2.56 GB | 7,839 |
| 2026-10-14 | 5.75 GB | 5,649 |
| 2026-10-23 | 93.22 GB | 34,448 |
| 2026-10-25 | 16.86 GB | 4,827 |
| 2026-10-26 | 10.84 GB | 3,103 |
Root cause
- One commit per vector. The backfill path loops per observation:
backfillVectorEmbeddings→queueSemanticVectorSafely→upsertSemanticVectors(dataDir, profile, [record])with a single record.mergeVectorsthen runsmergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows). Each call creates a new table version. - Every commit writes a full manifest. LanceDB manifests enumerate all live fragments. With N commits and N fragments, total manifest bytes grow O(N²). 64,610 commits × 2.15 MB average ≈ 138.8 GB of metadata for 657 MB of vectors.
- No compaction or cleanup. Neither 1.9.9 nor 1.10.1 calls
optimize()orcleanupOldVersions(), so every version and fragment is retained indefinitely.
Amplifier: cold-start re-embedding
hasObservationVector checks the in-memory Orama document's embedding, not the Lance table. hydrateIndexForStartup only restores vectors present in the embedding cache. With a 4096-dim model and the default MEMORIX_EMBEDDING_CACHE_MAX_BYTES = 256 MB (BYTES_PER_DIM = 8), the cache holds exactly 8,192 entries. The store has 42,059 vectors, so on every cold start about 33,867 vectors are classified as missing and re-embedded, each producing another commit.
Evidence: on 2026-10-23 there were 34,448 new table versions. 42,059 − 8,192 = 33,867, plus 303 new observations that day — an almost exact match. The cache also thrashes (re-embedding evicts older entries), so the next restart repeats the cycle with a different subset.
Impact
- 139.95 GB of metadata for 657 MB of vectors; the 500 GB volume dropped to 88 GB free.
- Recovery required
table.optimize({ cleanupOlderThan: new Date(), deleteUnverified: true }): 41,778 fragments → 2, 64,610 old versions removed, 149.45 GB reclaimed. - Without manual intervention the table keeps growing superlinearly on every restart.
Suggested fixes
- Batch backfill writes. Merge 100–500 rows per
mergeInsertinstead of one row per call. - Call
optimize()periodically (after N commits, or on startup) and/or expose amemorix index optimizecommand that runscleanupOldVersionswith a retention window. - Determine vector presence from the Lance table (or a persisted ID set) instead of the in-memory Orama cache, and hydrate from Lance on startup, so a cold cache does not trigger full re-embedding.
- Bound the cache by entry count and document the interaction with corpus size. Consider LRU eviction that does not cause existing rows to be re-embedded.
Reproduction
- Use an API embedding provider where corpus size exceeds cache capacity (e.g., 4096 dims, default 256 MB cache, more than 8,192 observations).
- Restart the control plane several times.
- Observe
_versions/grow by roughlycorpus − cache entriesper restart, anddata/accumulate one fragment per row. du -sh ~/.memorix/data/semantic-index/*.lance/_versions
Environment
- memorix 1.9.9 (checked 1.10.1: same per-row
insertObservationpath, still nooptimizecalls) - Windows 11 (10.0.26300), Node v24.15.0
@lancedb/lancedb0.38.0- Embedding:
qwen3-embedding:8b, 4096 dims, API provider (local Ollama-compatible endpoint) - Store: 52,819 observations, 42,059 vectors, 6 projects
Thanks for the detailed reproduction and disk breakdown. Fixed in v1.10.2 via #369: individual vector writes are batched, Lance tables are optimized periodically, and startup checks persisted Lance IDs before scheduling re-embedding or rewriting cached vectors. For an existing inflated index, stop Memorix processes using the shared data directory, then run memorix repair index from an associated Git project. This uses a 24-hour retention window and does not delete unverified files, so recent space may require a later rerun. Please do not delete Lance _versions or data files manually. v1.10.2 is available on npm, the MCP Registry, and GitHub Releases.