[Django] nplusone complains both with and without prefetch_related
Open
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I have a case where nplusone first complains that a `prefetch_related` is missing and once I add that it complains that the new `prefetch_related` is over-eager.
In more detail:
- The related part of the model is:
- Three Models: P, N and U
- Query starts at P, i.e. `P.objects.[..]`
- P has an m2m relation to N
- N has a foreign key towards U
- Initial error is:
`Potential n+1 query detected on "N.u"`
- Once I add `.prefetch_related('n__u')` it changes to:
`Potential unnecessary eager load detected on "P.n"`
Any thoughts other than whitelisting for a workaround?
Thanks in advance!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.