On eager fetching, ALL the related objects will be fetched. You don't really want to do this all the time as it is a resource consuming process.
On lazy fetching, only the object that is directly specified in the query is fetched. Only when we want to traverse along the relation, then only it will load the related objects. This will cause multiple queries to the database.
So, in my humble opinion, it is better to directly query (using the ORM's query language) for the objects that you need instead of being lazy and only depend on the ORM's fetching mechanism. Probably a bit hard to get it right if you aren't familiar with multiple table joins but seriously it is worth the time and yields better application performance.
Conclusion: a good software developer should not neglect learning database related aspect of the field.
So, in my humble opinion, it is better to directly query (using the ORM's query language) for the objects that you need instead of being lazy and only depend on the ORM's fetching mechanism. Probably a bit hard to get it right if you aren't familiar with multiple table joins but seriously it is worth the time and yields better application performance.
Conclusion: a good software developer should not neglect learning database related aspect of the field.
No comments:
Post a Comment