Changes between Version 3 and Version 4 of Ticket #35947, comment 3
- Timestamp:
- Nov 27, 2024, 4:05:44 PM (6 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35947, comment 3
v3 v4 15 15 Which is one for the top-level houses queryset, two for the `rooms__windows` prefetch, and three for the `stories__rooms__windows` prefetch where two are duplicates. As explained above, invasive changes would be required to take that number to 4 under circumstances that your specific schema design seems to be exhibiting because of how you denormalized `Room.house` (already available through `Room.story.house`) and `Window.story` (already available through `Window.room.story`). 16 16 17 If your application is executing 50x the number of 6 queries that could be reduced to 4 by implementing this optimization there is likely something else to look on your side before implementing this optimization. In other words `prefetch_related` is not a feature that systemically make elevated number of queries issues go away; it's a tool that bounds the N+1 query problem and not an identity mapper strategy #17 to accommodate yourdatabase denomalization needs.17 If your application is executing 50x the number of 6 queries that could be reduced to 4 by implementing this optimization there is likely something else to look on your side before implementing this optimization. In other words `prefetch_related` is not a feature that systemically make elevated number of queries issues go away; it's a tool that bounds the N+1 query problem and not an identity mapper strategy #17 to accommodate database denomalization needs.