Skip to content

Volume title search is an in-memory full scan (~6-7s cold) #265

Description

@paulyhedral

GET /volumes/search?q= is slow: 6-7s on a cold query, even for queries that return 0 results.

Evidence (dev, 2026-09-01)

query latency bytes
q=c 7.6s 71827
q=cele 7.4s 1183
q=celestialvo (0 results) 6.7s 12
repeat q=celestial 0.9s 1183 (warm)

Cold = full scan; warm is fast only because of WiredTiger cache + the route's CachePage wrapper.

Cause

catalog-data.go data.SearchVolumes (v0.15.0, data/volume.go:417) calls QueryVolumes(ctx, QueryParams{Limit: searchScanLimit}) to pull up to searchScanLimit fully-hydrated volume VOs, then filters in Go with strings.Contains(strings.ToLower(title), needle). Its own doc comment: "scanning the full collection ... in memory rather than pushing the match down to Mongo" (mirrors SearchPersons).

Suggested fix

Push the match to Mongo and cap hydration:

  • a title text index, or a normalized title_lower field with a regular index + anchored/prefix regex
  • return lightweight {id, title} projections, not full hydrated VOs
  • consider the same for SearchPersons and the other entity searches

Mitigation already shipped (frontend)

game-room-web now requires 3 chars and debounces 350ms before calling this endpoint (sweetrpg/game-room-web#434) — cuts the q=c worst case but not the 6s floor.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggoPull requests that update Go code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions