[PERFORMANCE] [MER-4066] Dashboard optimizations #5415
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.
This PR addresses a collection of performance issues in the Instructor Dashboard "Insights" tab, most prevalent in the "Practice Activities" and "Surveys" views.
There were two core performance issues:
The number of queries that needed to be run to display a collection of Practice or Survey activities (for a selected page) was proportional to the number of activities. I lost track of how many "per activity" queries were made, but I think it was around 3-5 per activity.
Some of the per activity queries and the non-per-activity queries run queried over the activity attempts table. For example, as a way to count the number of attempts. This is not scalable against production data.
The above two issues basically led to situations where the Practice Activities view was completely unusable for many courses in the system. You can see this right now on Proton by finding a decently large course, then trying to click on a practice page to see the activity details. The entire view just hangs.
The fix here was to re-implement the analytics gathering and preview rendering code to ensure that we:
So in other words, we put a constant upper bound on the number of queries made when a page is selected.