Home page: Optimize query for authorized students #2652
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.
Who is this PR for?
all educators
What does this PR do?
This optimizes
authorized { Student.active }
for educators with section assignments, impacting the home page feed, my students page, and many other parts of the product.It does this by removing calls to
Educator#labels
that end up doing authorization checks to see if the educator has any sections, in the process of computing dynamic labels. Since the only labels needs in the authorization method itself are static, optimize the call there to only look at static labels.I also initially reordered the condition checks related to housemaster authorization; these would run even if the feature was disabled through an env flag. This actually led to consistently slower p95 values on the
PerfTest
, so I noted it and backed that out.Data from Somerville, for sample of 5% of educators:
New Bedford will soon be impacted by this change, but for now the speedups only impact Somerville folks.
Separately, after this work and measurement, I noticed the
PerfTest
class defaults to all educators, and so updated that to useEducator.active
going forward.Checklists
Which features or pages does this PR touch?
Does this PR use tests to help verify we can deploy these changes quickly and confidently?