Draft: Attempt to use prefetch_related
Linked to ptf-site-traduction!10 (closed) and ptf-site-ahl!4 (closed)
Things to note :
- Avoid using
self.object_set.filter
as it creates another query. We should prefer using the a python-based filter on a prefetchedself.object_set
- Use
prefetch_related
when possible, as subsequent accesses create another SQL query otherwise - Avoid using
ptf.Resource.cast()
. This will cleanup the ORM cache for the object.
Edited by Nathan Tien You