Performance: OrWhere and advanced conditions
MEDIUM IMPACT
This affects how many database queries are generated and how complex they are, impacting server response time and page load speed.
$users = DB::table('users') ->where('status', 'active') ->where(function ($query) { $query->where('role', 'admin') ->orWhere('age', '>', 30); }) ->get();
$users = DB::table('users') ->where('status', 'active') ->orWhere('role', 'admin') ->orWhere('age', '>', 30) ->get();
| Pattern | Query Complexity | Server Load | Response Time | Verdict |
|---|---|---|---|---|
| Multiple root-level orWhere | High | High | Slow | [X] Bad |
| Grouped orWhere in nested where | Moderate | Lower | Faster | [OK] Good |