Final notes
We started with a very slow (1735ms) and memory-consuming (19.5MB) view, applied common optimisations for querysets using the hints and insights dj-tracker
provided us with and finished with a view that performs reasonably (48ms and 0.15MB).
We can also keep track of the view's performance over time in the dj-tracker
dashboard (e.g when we decide that we also want to show a book's summary).
Misc
-
dj-tracker
can automatically provide these additional hints:Use .count
,Use .exists
,Use .contains
-
You may not necesarily be able to apply all optimisations we did for our books query, however in many cases, you'll be able to apply some of them.
-
Use the
.iterator
optimisation with caution, ignoring the hint shown in the queryset page if necessary.