Skip to content

Commit

Permalink
Optimize inefficient database query in the deviation list view
Browse files Browse the repository at this point in the history
The course module name is no longer queried separately for
each deviation. This reduces the number of performed
queries significantly. Additionally, some large unnecessary
attributes are no longer loaded.

Fixes apluslms#1302
  • Loading branch information
ihalaij1 authored and rkdarst committed Dec 20, 2023
1 parent 322c157 commit e5c3e38
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deviations/viewbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def get_deviation_groups(
'submitter', 'submitter__user',
'granter', 'granter__user',
'exercise', 'exercise__course_module',
'exercise__course_module__course_instance',
)
.defer(
'exercise__exercise_info',
'exercise__description',
'exercise__course_module__course_instance__description',
)
# parent is prefetched because there may be multiple ancestors, and
# they are needed for building the deviation's URL.
Expand Down

0 comments on commit e5c3e38

Please sign in to comment.