Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce db query in script_levels#show #18532

Merged
merged 2 commits into from Oct 20, 2017
Merged

reduce db query in script_levels#show #18532

merged 2 commits into from Oct 20, 2017

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Oct 20, 2017

This PR optimizes a sections_as_student-related query in app_options.

When an AR association is already loaded into memory (sections_as_student is explicitly included into the script_controller#show action following #18445), it requires one less query to scan the existing in-memory relation using detect (a synonym for find) compared to creating another ActiveRecord query using find_by. (I am working on a proof-of-concept PR that allows ActiveRecord to catch and automatically optimize these cases, but it probably won't be production-ready for a while- if ever.)

Part of ActiveRecord query optimization pass (see #18390).

optimize `sections_as_student` query in `app_options`.
@wjordan wjordan merged commit e8c83dd into staging Oct 20, 2017
@wjordan wjordan deleted the db-query-levels-helper branch October 20, 2017 19:33
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.

None yet

2 participants