Skip to content

status crashes with 'too many SQL variables' at large drawer counts (123k+) #950

@5vitl

Description

@5vitl

[RozumLife Agent Team on behalf of Vitali B:]

Summary

mempalace status raises a ChromaDB InternalError (SQLite too many SQL variables) when the palace contains a large number of drawers. In our case: 123,050 drawers, 794 MB database.

Steps to reproduce

  1. Mine a large project directory without --limit until the palace exceeds ~32k drawers
  2. Run mempalace status

Error

chromadb.errors.InternalError: Error executing plan: Internal error: error returned from database: (code: 1) too many SQL variables
  File "mempalace/miner.py", line 826, in status
    r = col.get(limit=total, include=["metadatas"]) if total else {"metadatas": []}

Root cause

cmd_status queries each collection with col.get(limit=total, include=["metadatas"]). When total is large (≥ ~32,767 depending on the SQLite build), ChromaDB's internal query generates more SQL bind variables than SQLite allows, causing the crash.

Environment

  • mempalace: 3.3.0
  • chromadb: 1.5.7
  • OS: Windows 11 (SQLite variable limit is platform-independent)
  • Palace size: 123,050 drawers, 794 MB (chroma.sqlite3)

Impact

  • status — crashes (unusable at scale)
  • compress — crashed in v3.0.0 with the same error; fixed in v3.3.0 ✓
  • search, mine, compress (v3.3.0) — all work correctly at this scale ✓

Suggested fix

Paginate the col.get() call in cmd_status rather than fetching all entries in a single query:

PAGE = 5000
offset = 0
metadatas = []
while True:
    batch = col.get(limit=PAGE, offset=offset, include=["metadatas"])
    if not batch["metadatas"]:
        break
    metadatas.extend(batch["metadatas"])
    offset += PAGE

This is the same pattern that fixed the v3.0.0 compress crash. The compress fix in v3.3.0 already uses chunked fetching — status just needs the same treatment.

Notes

  • compress in v3.3.0 successfully processed all 62,963 drawers with no SQL error, confirming chunked fetching works.
  • Workaround: use mempalace search "" with --wing / --room filters to get approximate per-room counts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions