MongoDB's slow-query log (24 h, >100 ms) showed four shapes:
- Admin repository search: a case-insensitive substring regex over four
fields scanned all ~300k repositories, three times per page (up to 5.2 s
each). Searches that are a repository ID or owner/name now match
through the indexes first and only fall back to the regex otherwise.
- Admin errors page owner lookup: repoId $in without the repoId index's
collation was a full collection scan. It now uses the collation.
- Status breakdown and home stats aggregates (~0.4 s over every
repository, ~100 runs a day from admin polling): cached for a minute,
and the admin overview uses the existing hourly home-stats cache.
- Folder counts for large repositories (0.7-1.5 s, 400-550k index keys)
are cached per tree generation, which never changes; legacy trees are
keyed by commit for 5 minutes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>