Opened 4 hours ago

#37143 new Bug

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

Reported by: Jacob Walls Owned by:
Component: Database layer (models, ORM) Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no 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 (0)

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