[Django] #34331: Support prefetch_related() with Queryset.aiterator()

76 views
Skip to first unread message

Django

unread,
Feb 11, 2023, 8:49:13 AM2/11/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry | Owner: nobody
Johnson |
Type: New | Status: new
feature |
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Asynchronously iterating through a QuerySet that contains a
prefetch_related definition is not supported in the alpha release of 4.2,
but would be a quite useful feature.

If the iterator is chunked, related objects could be prefetched in a
manner much like within QuerySet.iterator(), as long as the call to
prefetch_related_objects is wrapped by sync_to_async().

--
Ticket URL: <https://code.djangoproject.com/ticket/34331>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 11, 2023, 10:47:44 AM2/11/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:1>

Django

unread,
Feb 11, 2023, 1:06:01 PM2/11/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: Barry
| Johnson
Type: New feature | Status: assigned

Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Barry Johnson):

* owner: nobody => Barry Johnson
* status: new => assigned
* has_patch: 0 => 1


Comment:

Added PR https://github.com/django/django/pull/16543

(There are two commits -- the second one simply changes the order of an
import statement. This GitHub newbie has been unable to find the "Squash
and Merge" button anywhere on the GitHub user interface, nor find any
documentation that says how to reach that button.)

--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:2>

Django

unread,
Feb 12, 2023, 9:18:58 PM2/12/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: Barry
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

Thanks for the patch, I left some comments about on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:3>

Django

unread,
Jul 27, 2023, 9:05:38 PM7/27/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton

Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by john-parton):

* owner: Barry Johnson => john-parton


--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:4>

Django

unread,
Jul 27, 2023, 9:08:40 PM7/27/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by john-parton):

Open pull request here https://github.com/django/django/pull/17118

I have one basic test and the minimal change to documentation there.

--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:5>

Django

unread,
Jul 27, 2023, 9:35:18 PM7/27/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:6>

Django

unread,
Jul 31, 2023, 6:04:30 AM7/31/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:7>

Django

unread,
Jul 31, 2023, 11:28:08 AM7/31/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by john-parton):

Updated my pull request

--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:8>

Django

unread,
Jul 31, 2023, 3:18:44 PM7/31/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:9>

Django

unread,
Jul 31, 2023, 4:00:51 PM7/31/23
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: closed

Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"fff14736f1cc594f79ea0e2656b8375d837b7aca" fff1473]:
{{{
#!CommitTicketReference repository=""
revision="fff14736f1cc594f79ea0e2656b8375d837b7aca"
Fixed #34331 -- Added QuerySet.aiterator() support for prefetch_related().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:10>

Django

unread,
Apr 22, 2024, 4:05:15 PM4/22/24
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by nessita <124304+nessita@…>):

In [changeset:"36b7024b7fc881b319a2b67876e4f72ba680d6a8" 36b7024]:
{{{#!CommitTicketReference repository=""
revision="36b7024b7fc881b319a2b67876e4f72ba680d6a8"
Fixed #35392, Refs #34331 -- Allowed importing aprefetch_related_objects
from django.db.models.

Thanks James Ostrander for the report and fix, and to Tim Graham and
Mariusz Felisiak for the reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:11>

Django

unread,
Apr 22, 2024, 4:06:44 PM4/22/24
to django-...@googlegroups.com
#34331: Support prefetch_related() with Queryset.aiterator()
-------------------------------------+-------------------------------------
Reporter: Barry Johnson | Owner: john-
| parton
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"ea81c9d343a400b537caaafb47d03676c03df246" ea81c9d]:
{{{#!CommitTicketReference repository=""
revision="ea81c9d343a400b537caaafb47d03676c03df246"
[5.0.x] Fixed #35392, Refs #34331 -- Allowed importing
aprefetch_related_objects from django.db.models.

Thanks James Ostrander for the report and fix, and to Tim Graham and
Mariusz Felisiak for the reviews.

Backport of 36b7024b7fc881b319a2b67876e4f72ba680d6a8 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34331#comment:12>
Reply all
Reply to author
Forward
0 new messages