7 ms·
This +1. I've been burned before when using ORMs which translate simple-looking queries to terribly inneficient SQL statements underwater.
by leeuw01 3y ago
This +1. I've been burned before when using ORMs which translate simple-looking queries to terribly inneficient SQL statements underwater.
- danielvaughn 3y agoYeah I’m a web dev, and recently I found out the most popular JS ORM doesn’t produce joins. It’ll just execute multiple queries in sequence. I don’t know how common that is in the ORM landscape but for me that’s a deal breaker.
- smaddox 3y agoCommon enough to have a name: the N+1 query problem.
- Izkata 3y ago1+N is clearer I think, and what I remember seeing in the past - it matches what's actually happening with this problem. First time I saw N+1 sometime around a year ago, I had no idea it referred to the same thing and thought it was something different. N+1 looks like an issue with aggregation after a parallel run, something I've encountered with celery tasks before.
- setr 3y agoThat’s just a direct result of lazy loading — if you don’t grab the related objects in the initial query, then there’s no joins to be had. Most ORMs do lazy loading by default, but also have a way of doing eager loading — either requiring the nested object to always be loaded as well, or dropping down to some pseudo-sql. In c#/EFCore, I always prefer to avoid lazy loading and just write LINQ, and just use the ORM to map the resultset back to objects