Looping over a collection to count or sum related rows is a classic N+1. Eloquent has a single-query answer for every common case.
#Performance
Articles
When a dataset is too large to hold in memory as a Collection, LazyCollection processes it one item at a time using generators.
Calling ->get() on a giant table loads every row into memory at once. Laravel gives you chunk, chunkById, cursor, and lazy to process big result sets safely.
Laravel's June 2026 updates added Bus::bulk(), which queues large batches of jobs with a single database insert per connection instead of one write per job.
Building a CSV export that holds an entire table in memory works until the table grows. Here is how to stream a download row by row so memory stays flat.
Eloquent will happily hide an N+1 query until it hits production. Strict model mode turns those silent mistakes into loud exceptions during development.
A handful of Artisan optimization commands shave real milliseconds off every request in production. Here is what each one does and when to run it.
A new @fonts Blade directive backed by a Vite font runtime lands in Laravel 13.x, handling preload tags, @font-face rules, and CSP nonces for you.
Caching is the fastest performance win in Laravel, but only if you do it right. These tips cover remember, cache stampedes, tagging, and atomic locks.
Stop making users wait for logging, cleanup, or metrics work that could run after the response is already on its way to the browser.