Changes between Initial Version and Version 1 of Ticket #36157


Ignore:
Timestamp:
Jan 29, 2025, 4:26:56 PM (25 hours ago)
Author:
Tim McCurrach
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36157 – Description

    initial v1  
    11When prefetching related models. If you apply `.only()` to the related queryset, django performs additional lookups for related IDs that have been left out of the `only`.
    22
    3 It is probably easiest to explain the issue with an example. Suppose you have these models:
     3It is probably easiest to explain the issue with an example.
     4
     5=== Example Situation ===
     6
     7Suppose you have these models:
    48
    59{{{
     
    3842I can understand it might be a good idea to have the related-id's for the blog on hand should you need them later. But I also think, that by using `.only()` you are explicitly telling django - I don't need these. This is a real problem for larger data-sets, where you end up with thousands of extra round-trips to the database.
    3943
     44=== Context ===
     45
     46This is an issue that came up in the wild. I'm using a third-party optimiser that improves the performance of graphQL queries by decorating querysets with `only()`, `select_related()` etc. It correctly identifies that I am only using certain fields and applies `only()` to them, knowing I will never need to access certain related fields. This results in django producing many additional hits to the database.
Back to Top