Skip to content

Index run_hash so admin hide/delete/search by hash is instant#579

Merged
ptrlrd merged 1 commit into
mainfrom
fix/run-hash-index
Jul 10, 2026
Merged

Index run_hash so admin hide/delete/search by hash is instant#579
ptrlrd merged 1 commit into
mainfrom
fix/run-hash-index

Conversation

@ptrlrd

@ptrlrd ptrlrd commented Jul 10, 2026

Copy link
Copy Markdown
Owner

The admin "look up a run by hash → hide/delete" flow is slow (seconds) — hiding e7ad725372d1af64 "took forever."

Cause: those operations match on the run_hash field, which is unindexed, so every lookup is a full collection scan of the ~740k-doc runs collection. (_id is the hash for single-player runs and is indexed; multiplayer runs carry a shared run_hash field.)

Fix: add a sparse index on run_hash. With it, the $or: [{_id}, {run_hash}] lookup used by the hide/delete/search fix (#577) becomes an index union instead of a scan — instant. Sparse because only multiplayer docs have the field, so the index is small and cheap to build.

One line, ruff clean. The index builds on startup via _ensure_indexes (idempotent).

Note: this + #577 both need the prod backend to actually deploy to take effect — the CI built the images but the deploy/restart step is separate and hasn't run, which is also why hiding is still slow and single-player hides don't stick on live right now.

Looking a run up by hash (admin search, hide, delete) matched on the run_hash
field, which is unindexed, so every lookup was a full scan of the ~740k-doc runs
collection (seconds). _id is the hash for single-player runs and is indexed;
multiplayer runs carry a shared run_hash field. Add a sparse index on run_hash so
the $or: [{_id}, {run_hash}] lookup (from the hide/delete fix) is an index union
instead of a collection scan. Sparse because only multiplayer docs have the
field, so the index stays small.
@ptrlrd ptrlrd merged commit 5d3a21f into main Jul 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant