3 ms·
Any ORM built around implicit lazy loading is doomed. The idea in itself is simply stupid. The ideal usecase for lazy loading is that you have a single object,
by imtringued 3y ago
Any ORM built around implicit lazy loading is doomed. The idea in itself is simply stupid. The ideal usecase for lazy loading is that you have a single object, e.g. a user page and then you never load a collection of objects. The fact that you end up doing a few more queries doesn't matter.
ORM Framework developers have optimized their framework for rare cases. You can see this most clearly with Hibernate. If you want to initialize entities, you must either use an extremely convoluted JOIN FETCH statement, which doesn't really work the way you think it should work and can't be composed, or you choose to use entity graphs, which are a horrific contraption of Java annotations. The Rails style include method is a reasonably sane solution, but again, why can you load that association via lazy loading in the first place? The unpredictable performance of ORMs emerges from the fact that you write a query, which then gets you a hollow shell of an object, containing landmines which can blow up and trigger additional queries, long after the original query. The call to the framework and it's actual communication with the database are temporally disconnected.
- deleted 3y ago[deleted]