An N+1 happens when you load N parent rows, then issue one extra query per row for a relation — classic ORM footgun.

Symptom

One query for posts, then dozens of identical SELECT * FROM users WHERE id = ? in logs.

Eloquent eager load

Post::with('author')->get();

For nested: with(['author', 'comments.user']).

Constraint eager loading

Post::with(['comments' => fn ($q) => $q->where('approved', true)])->get();

When JOIN beats eager

Reporting or filters across relations may use join or subqueries to avoid hydration overhead.

Verify

Enable query log locally; use Laravel Telescope or DB::listen. In SQL, EXPLAIN ANALYZE confirms index use.