Enable map counting workers with two grouped SQL statements - #22
Merged
Conversation
Replace the never-enabled per-map count jobs (one BullMQ job per map, three queries each) with a single map-count job running one grouped UPDATE. The full recompute of playerCount/clanCount/gameServerCount scans PlayerInfoMap and ClanInfoMap once (~160s in production) and runs daily; a gameServerCount-only refresh (67ms) runs hourly. Both skip rows whose counts are unchanged. Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The map counting workers were never enabled because one BullMQ job per map (~95k maps, three queries each) was too expensive. This replaces the per-map fan-out with two typedSql statements that update all map counters at once and skip rows whose counts are unchanged. A daily
fulljob recomputesplayerCount/clanCount/gameServerCountin one grouped pass (measured ~160s against the production database, read-only), and an hourlygameServersjob refreshes onlygameServerCountfrom the 911-rowGameServerStatetable (measured 67ms). Themap-countqueue now carries amodefield with per-mode deduplication,mapScheduler()is wired into the scheduler, and the unusedUPDATE_MAPS_COUNTS_CONCURRENCYenv var is dropped. Verified on a local dev database (616/621 stale maps populated, second run writes 0 rows) and status-page exports are unchanged.🤖 Generated with Claude Code