rendering the module's name causes new queries for each record because it needs to load the course instance for the module numbering settings (that set Arabic or Roman numerals). Has select_related() or prefetch_related() been used incorrectly since the code tries to prefetch the course instances?
does the variable in the template benefit from the prefetching in the queryset or is the queryset's cache somehow lost when the template is rendered in this case? Does the variable refer to the original queryset anymore at that stage?
when all deviations in the course are queried, the query includes a lot of unnecessary attributes. Loading them from the database consumes a lot of resources. Especially the large JSON fields in the exercise model consume a lot of bandwidth even though those attributes are not used at all in the deviations list.
Unwanted attributes can be avoided with the Django queryset methods only() and defer().
exercise.exercise_info is one of the unnecessary attributes in this case.
1122 presented performance issues in the deviations list page. This new issue focuses on specific performance issues.
Using the Django Debug toolbar, we have noticed that the database queries in the deviations list page include some very inefficient parts.
select_related()
orprefetch_related()
been used incorrectly since the code tries to prefetch the course instances?only()
anddefer()
.exercise.exercise_info
is one of the unnecessary attributes in this case.