Performance: Query optimization
HIGH IMPACT
This affects how fast the database queries run and how quickly the page can show data to users.
$posts = Post::with('user')->get(); foreach ($posts as $post) { echo $post->user->name; }
foreach ($posts as $post) {
echo $post->user->name;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| N+1 Query Pattern | Low | 0 | Low | [X] Bad |
| Eager Loading with with() | Low | 0 | Low | [OK] Good |