Eager Loading with Laravel

Eager Loading with Laravel

by

May 30, 2019

0

85

Object Relation mapping, or ORM for short, makes working with databases extremely simple. While defining relationships in an object-oriented way makes it easy to query related model data, the underlying database calls are often overlooked by developers. A standard database optimization for an ORM is eager-loading related data.

Introduction

At the simplest level, ORMs lazy-load related model data. After all, how’s the ORM supposed to know your intention? Perhaps you will never actually use the related model’s data after querying the model. Not optimizing the query is known as a “N+1” issue. When you use objects to represent queries, you might be making queries without even knowing it.In this video I will cover how we can optimize our query to increase performance and decrease resource consumptions.

 

Need to know how to do something? Want to see it done? Contact us.