models.py
5.31 KB
-
Optimize the query in `bulk_lookup_kwargs` for QuerySet args. · 5a9338ae
When passing a QuerySet to bulk_lookup_kwargs(), the queryset was undesirably executed to get a list of IDs. This causes an unnecessary performance loss. There is no need to loop over a QuerySet to execute a IN (1, 3, 4) query. Instead, just allow the ORM and database to execute a IN (SELECT id FROM ..) query. In a real life app with a large set of objects, the difference in performance is noticeable.
Diederik van der Boor committed