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 #1302
  • Loading branch information
ihalaij1 committed Nov 13, 2023
1 parent c23b710 commit a3ac989
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 a3ac989

Please sign in to comment.