Opened 6 years ago
Last modified 2 years ago
#29984 closed New feature
Support prefetch_related() with Queryset.iterator() — at Version 4
Reported by: | Taylor H | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I was surprised when I found out that prefetch_related
calls are ignored when using Queryset.iterator
. I noticed in the docs here https://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator that it is because the "these two optimizations do not make sense together." That may have been true in the past, but it is definitely not the case now. The iterator allows chunking (by default 2000) and it would be very helpful to prefetch related for each chunk.
Change History (4)
comment:1 by , 6 years ago
Summary: | Support prefetch_related with Queryset.iterator → Support prefetch_related() with Queryset.iterator() |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 6 years ago
I've created a proof of concept implementation https://github.com/django/django/pull/10707/
I think prefetching is probably closer to what a user would expect from the api.
comment:3 by , 5 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
comment:4 by , 5 years ago
Description: | modified (diff) |
---|---|
Version: | 2.1 → master |
The situation isn't completely straightforward. There's a discussion on django-developers. Accepting the ticket to do something.