Re:Ask HN: What happened to the ORM?
by spookylukey on Thursday June 29, 2017 @06:18AM
(#14662058)
This is not the case - with Django's ORM you are still susceptible to the N+1 problem. It can be largely mitigated through `select_related` and `prefetch_related`, but the fundamental issue is there - that simply by accessing an attribute for an object that wasn't already fetched, you can do another database query without it being at all clear in the code that this will happen.
That's true, though select_related is mostly the default, and that behaviour is documented well. In practice, I very seldomly find N+1 cases with Djangos ORM, even when doing relatively complex data analysis.
Re:Ask HN: What happened to the ORM?
by peterbraden on Thursday June 29, 2017 @07:25AM
(#14662306)
This didn't use to be the case, I remember a single line of Django orm causing several hundred db requests, but maybe they improved it.
Re:Ask HN: What happened to the ORM?
by gjjrfcbugxbhf on Thursday June 29, 2017 @09:33AM
(#14663125)
When was that and what was the form of the query?
That isn't true for e.g. Django's ORM, which lazily evaluates the query and only actually accesses the db after that, with a single query, and filtering done in SQL.