#16855: select_related doesn't chain as expected -------------------------------------+------------------------------------- Reporter: Leo | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: master (models, ORM) | Resolution: fixed Severity: Normal | Triage Stage: Ready for Keywords: | checkin Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by mrmachine): Please do not further reduce the functionality of `select_related()` by removing the no-arguments variant (select all related, with a high hard coded depth limit to prevent recursive joins). I use `select_related()` with no arguments all the time, as I have found that in almost all my use cases, following too many joins and returning more data than may be necessary is still much more performant than returning too little data, and subsequently having template authors generate additional queries by accessing related fields that were not selected in the view. It also saves the view programmer from tediously listing larger numbers of related fields when they legitimately want to select most or all related fields, and avoids the need for view programmers to know in advance which related fields a template author will want to access. I much rather fallback to naming explicit fields in `select_related()` only when there is an actual performance problem because of too many joins, instead of premature optimisation by trying to explicitly list all relations, and having to re-visit that code when a template or model changes. -- Ticket URL: <https://code.djangoproject.com/ticket/16855#comment:38> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.390c49f485e300b5637ab88e129f372a%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.