Skip to content

perf(api): batch leaderboard stat lookups#846

Open
ugcodrr wants to merge 1 commit into
mainfrom
perf/batch-leaderboard-stats
Open

perf(api): batch leaderboard stat lookups#846
ugcodrr wants to merge 1 commit into
mainfrom
perf/batch-leaderboard-stats

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented May 12, 2026

Summary

  • replace per-row player leaderboard stat lookups with a single Mongo query using uuid: { $in: ids }
  • replace per-row guild leaderboard stat lookups with a single Mongo query using id: { $in: ids }
  • preserve Redis leaderboard ordering by mapping fetched documents back to the original id list
  • include the document id fields in the projection so the batched lookup can build stable lookup maps without fetching full documents

Why / Benefits

  • Reduces leaderboard additional-stat hydration from up to 10 Mongo round trips per page to one query per leaderboard page.
  • Lowers Mongo connection pressure and API overhead while keeping the response shape and ordering unchanged.
  • Keeps the existing projection behavior for additional fields, only adding the id field needed for remapping.

Validation

  • pnpm --filter api test:types
  • pnpm --filter api lint

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
statsify Building Building Preview May 12, 2026 0:11am

@github-actions github-actions Bot added the api label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant