Concept Flow - Lazy loading and N+1 prevention
Start Query for Posts
Lazy Load Posts
Access Related Comments?
No Extra Query
N+1 Problem if in Loop
Use Eager Loading to Prevent N+1
Single Query for Comments
Display Data
End
This flow shows how lazy loading fetches related data only when accessed, which can cause many queries (N+1 problem), and how eager loading prevents this by fetching all needed data upfront.