Performance: Aggregates (count, sum, avg)
MEDIUM IMPACT
This affects how quickly the database returns summary data and how much data the server processes before sending results to the browser.
$count = User::count(); $sum = User::sum('orders_total');
$users = User::all(); $count = $users->count(); $sum = $users->sum('orders_total');
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Loading full dataset then counting/summing in PHP | N/A (server-side) | N/A | N/A | [X] Bad |
| Using database aggregate functions (count, sum, avg) | N/A (server-side) | N/A | N/A | [OK] Good |