Skip to content

Draft: Attempt to use prefetch_related

Nathan Tien You requested to merge prefetch_related into master

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 prefetched self.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

Merge request reports

Loading