Opened 3 weeks ago

Closed 7 days ago

#37143 closed Bug (fixed)

aiterator() missing check for chunk_size=None after prefetch_related()

Reported by: Jacob Walls Owned by: zky
Component: Database layer (models, ORM) Version: 5.0
Severity: Normal Keywords:
Cc: Simon Charette 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

aiterator() is missing the check found in iterator() for chunk_size=None after prefetch_related():

iterator() version:

        if chunk_size is None:
            if self._prefetch_related_lookups:
                raise ValueError(
                    "chunk_size must be provided when using QuerySet.iterator() after "
                    "prefetch_related()."
                )

I think this should have been implemented in #34331.

The rationale for the check was to alert users that the number of queries could spike with small batch sizes, which you might be tempted to minimize if prioritizing memory optimizations.

Change History (10)

comment:1 by zky, 3 weeks ago

Owner: set to zky
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by zky, 3 weeks ago

Has patch: set

comment:4 by Jacob Walls, 2 weeks ago

Cc: Simon Charette added
Needs documentation: set
Patch needs improvement: set

Needs a release note, and now that I think of it, probably a deprecation path as well given that we accidentally supported this.

in reply to:  4 comment:5 by zky, 2 weeks ago

Replying to Jacob Walls:

Needs a release note, and now that I think of it, probably a deprecation path as well given that we accidentally supported this.

I have changed the behavior from raising an exception to issuing a deprecation warning.And I have also added/updated the documentation.

Last edited 2 weeks ago by zky (previous) (diff)

comment:6 by zky, 2 weeks ago

Patch needs improvement: unset

comment:7 by Jacob Walls, 10 days ago

Patch needs improvement: set

comment:8 by zky, 8 days ago

Patch needs improvement: unset

comment:9 by Jacob Walls, 8 days ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:10 by Jacob Walls <jacobtylerwalls@…>, 7 days ago

Resolution: fixed
Status: assignedclosed

In ca5746b:

Fixed #37143 -- Added missing chunk_size=None check to QuerySet.aiterator().

Co-authored-by: Jacob Walls <jacobtylerwalls@…>

Note: See TracTickets for help on using tickets.
Back to Top