Commit c860fb1
authored
fix(sqlite_exact): speed up query and status on large palaces (#2308)
sqlite_exact.query() loaded every document and metadata blob to do
Python-loop cosine on the whole collection. On a 167k-drawer palace
that made mempalace_search 6-9s and mempalace_status 7s (paging every
metadata row because sqlite_exact had no facet_counts).
Rank from the embedding column with vectorized numpy cosine, hydrate
only the top-k documents, and cache the matrix plus wing/room/source_file
on the long-lived handle. Add facet_counts and sqlite_wing_room_counts
so status/list_wings use one GROUP BY. Advertise supports_metadata_facets
and expose collection._backend so the MCP facet path runs through the
embedding wrapper.
Live palace (167k drawers / 166k closets):
status 6997ms -> 1045ms
search warm 6364ms -> 210-1600ms
search cold 8236ms -> 5299ms (first matrix load)1 parent 4e3a3dd commit c860fb1
3 files changed
Lines changed: 524 additions & 41 deletions
0 commit comments