Skip to content

Performance: Optimize authorized students query for lower-access users - #2574

Merged
kevinrobinson merged 1 commit into
masterfrom
patch/educator-label-optimization
Aug 29, 2019
Merged

Performance: Optimize authorized students query for lower-access users#2574
kevinrobinson merged 1 commit into
masterfrom
patch/educator-label-optimization

Conversation

@kevinrobinson

Copy link
Copy Markdown
Contributor

Who is this PR for?

educators

What problem does this PR fix?

Optimizes authorized { Student.all } style queries. These are used in the home page feed and my students pages, among other places. It came up working on some unrelated features that performance regressed here for folks who fall through to the later lines in why_authorized_for_student?

What does this PR do?

Essentially removes n+1 across students, and moves the query in this method into something that can be eagerly included or cached on the Educator model or collection, and adds a short-circuit case too.

Numbers on PerfTest.authorized are pretty clear:

somerville
  before median: 7627ms    p95: 14195ms   (1% sample)
  after  median:  540ms    p95:  1197ms   (1% sample)
  revert median: 7294ms    p95:  8967ms   (1% sample)
  after  median:  720ms    p95:  6625ms  (10% sample)

new_bedford
  before median: 30805ms   p95: 43297ms   (1% sample)
  after  median:  1125ms   p95:  1762ms   (1% sample)
  after  median:  1527ms    p95: 2693ms  (10% sample)

bedford
  before median: 1719ms    p95: 2143ms   (1% sample)
  after  median:   99ms    p95:  172ms   (1% sample)
  after  median:  101ms     p95: 163ms  (50% sample)

Checklists

Which features or pages does this PR touch?

  • Home page
  • My Students
  • Core

Does this PR use tests to help verify we can deploy these changes quickly and confidently?

  • Included specs for changes
  • Manual testing made more sense here

@kevinrobinson

Copy link
Copy Markdown
Contributor Author

selfie

@kevinrobinson
kevinrobinson merged commit 6b36285 into master Aug 29, 2019
@kevinrobinson
kevinrobinson deleted the patch/educator-label-optimization branch August 29, 2019 23:14
@kevinrobinson kevinrobinson changed the title Authorized students: Optimize query for lower-access users Performance: Optimize authorized students query for lower-access users Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant