Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Reduce database calls when generating problem responses report (#…
…33940) During the process of generatinng report for problem responses, there are two places where N + 1 query problem exist. In both cases, `StudentModule` objects are fetched and looped over where `student.username` field for each object is accessed. This result in a seperate database call to get the username for each student response. This problem is fixed by creating a join to fetch the related table in the original query using `select_related`. In a test conducted on report having 5000 `StudentModule` objects, the number of queries for the request reduced from 8363 to 29. The total time taken for the task reduced from 23764 ms to 7394 ms.
- Loading branch information