eliminate second call to expensive query #861
Merged
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 query used to determine the latest masters of a set and highest scorers for a set is very intensive when a set has a lot of users as it has to calculate every user's score for the set and the datetime of the last achievement earned by the user from the set.
The current implementation runs the query twice, once for High Scores, and once for Latest Masters. This PR runs it once to determine both.
In my dev env, this eliminated 25% of the time spent generating the game page for Super Mario Bros. (6.6s down from 8.8s), which has 5186 unique users for which those values had to be calculated.
I'm not sure if this will translate directly to the live site. The live Super Mario Bros. set has over 17k users, and Super Mario World has over 27k users. Both of these pages took me more than 15 seconds to load. Even shaving 4 seconds (~25%) off those times would be beneficial.