News for hackers. Stuff that matters.
Re:Ask HN: What happened to the ORM? by bildung on Thursday June 29, 2017 @06:07AM (#14662025)
> This isn't remotely true; it turns what looks like an in-memory access into a network round trip. Navigating your database using an idiom of lists and member accesses is a fast path to n+1 queries all over the place, or ORM tuned to eagerly fetch the whole world when you only touch a tiny piece of it.

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.

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.
Re:Ask HN: What happened to the ORM? by bildung on Thursday June 29, 2017 @06:25AM (#14662087)
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?