Changes between Initial Version and Version 1 of Ticket #36157
- Timestamp:
- Jan 29, 2025, 4:26:56 PM (25 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #36157 – Description
initial v1 1 1 When 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`. 2 2 3 It is probably easiest to explain the issue with an example. Suppose you have these models: 3 It is probably easiest to explain the issue with an example. 4 5 === Example Situation === 6 7 Suppose you have these models: 4 8 5 9 {{{ … … 38 42 I 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. 39 43 44 === Context === 45 46 This 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.