Speed up permission retrieval from the database considerably. #4
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.
Instead of retrieving the permissions for all users with one query to the database for each user, get them all in a single query.
From the develop branch to the feature/classlist-permissions branch the timing for the load of the classlist editor page for a course with more than 18,000 users increased from 240 milliseconds to 1.69 seconds. That is a considerable slow down. The main reason for this is what is changed here. This brings the page load time back down to 549 milliseconds. Of course those timings are from one page load, but similar timings occur on repetition.
This is still twice as long as long of a load time as before. Part of this is because previously when loading a large class (more than 200 users) no permissions were loaded at first since only the permissions for visible users were loaded. Although, timing shows that with the change suggested here the user and permission queries are about the same as before. Timing further shows that the real slow down is the sorting. Previously only visible users were sorted. Now all users are sorted regardless of which are shown.