TICKET-574: Implement assignment caching #7787
Open
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.
Proposed Changes
Multiple individuals have reported slow MarkUs load times when viewing assignments, as TAs. Our investigation has found that we are running into the common N + 1 query problem. When loading the information displayed on the
statuscolumn of the assignment index page, we are performing 2 calculations per assignment, each doing a join on the membership table. There are currently more than 300K rows on the membership table. This means that every assignment scans through 300K membership records.If there are 10 assignments assigned to a particular TA, this means that there will be approximately 20 queries each scanning ~300K membership rows (we lack indexes as well) -> ~6 million row scans per page load.
To resolve this issue, we can preload all of the TA statistics and then return this information as a hash, where each key is associated to an assignment id and each value, to the status of that assignment,
num_markedornum_assigned. This means we are doing a single expensive query and then presenting this data almost immediately when subsequently asked for it.Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)