jmcarp / nplusone

Auto-detecting the n+1 queries problem in Python
MIT License
996 stars 47 forks source link

Feature request: Handle Django deferred fields #39

Open shaib opened 3 years ago

shaib commented 3 years ago

This library is very helpful in the classic 1+n scenario, where the n queries are caused by following relationships.

There is another, less common scenario, with similar consequences: The original query defers some field, and then the field is accessed when going over the objects. It may seem very unlikely, because deferring has to be done explicitly, but can still happen when the deferring and the access are done in different parts of the code, and much like the classic case, can be improved by adding a call (e.g. defer(None)).