#35779: ORM to avoid deferring the reference_id of a prefetch
-------------------------------------+-------------------------------------
Reporter: Thiago Bellini | Owner:
Ribeiro | GunSliger00007
Type: Uncategorized | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Thiago Bellini Ribeiro):
Replying to [comment:2 GunSliger00007]:
>
>
> Consider optimizing your queries by prefetching only the fields you
need. In your case, you’re already using only() to limit the fields loaded
by the query, which helps reduce the amount of data loaded into memory.If
the related Email objects are large, consider using .values() or
.values_list() to reduce the amount of data furthe
>
>
> {{{
> User.objects.prefetch_related(
> Prefetch("email_set", queryset=Email.objects.only("user_id",
"email"))
> )
> }}}
>
That `User`/`Email` was mostly to exemplify the issue :)
--
Ticket URL: <https://code.djangoproject.com/ticket/35779#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070192116f406d-2eb15e48-61d3-4ec8-8dc5-4fed4ca2510e-000000%40eu-central-1.amazonses.com.