Skip to content

perf(api): batch leaderboard page lookups into one $in query - #1002

Open
ugcodrr wants to merge 4 commits into
mainfrom
fix/batch-leaderboard-stats
Open

ugcodrr wants to merge 4 commits into
mainfrom
fix/batch-leaderboard-stats

Conversation

@ugcodrr

@ugcodrr ugcodrr commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Description: Leaderboard pages ran one database query per row, and rows whose player or guild no longer exists came back with no name.

  1. Missing rows are dropped and logged, and the others keep their real positions, so a page can read 41, 42, 44.
  2. If every row on a page is missing, the page comes back empty and the next button can't get past it.

A full page loads in 3.2 ms instead of 6.7 ms at the median, and 25 ms instead of 51 ms with eight at once.

Merge order for the perf PRs, one at a time: #1005, #1006, #1007, #1002, #1009, #1010, #1011, #1014, #1012, then #1003 last.

Conflicts with #875 and with #1122, which batches the player lookup its own way.

Testing: redis-cli ZADD player.stats.bedwars.overall.wins 999999 00000000000000000000000000000000, then open /leaderboard bedwars. The fake row is gone and the page starts at #2.

Supersedes #846

getAdditionalStats ran one findOne per row, ten per page, for both player and guild
leaderboards. It now runs a single find with $in and puts the rows back in Redis order.

A row whose player or guild document is missing from Mongo used to come back with no
name. It is now left out of the page, the other rows keep their Redis positions, and
the API logs how many rows each page dropped.
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
statsify Ignored Ignored Oct 22, 2026 4:38am UTC

@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

Deployment failed for project statsify with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/statsify-net?upgradeToPro=build-rate-limit

This branch was previously deployed

1 inactive (outdated) deployment
Preview — 49f6a0e6 Deployed Oct 21, 2026 by vercel[bot]
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