N+1 queries usually get discovered in production. This one setting makes Eloquent throw the moment they happen locally instead.
#Performance
Articles
Calling five APIs one after another adds up their latencies. Http::pool() fires them concurrently and waits once.
Eager loading the parent relation still triggers a query per child model. chaperone() closes that gap for free.
Laravel's once() helper memoizes a closure's return value for the current request or process — here's when to reach for it.
Cache::flexible() serves stale data while refreshing it in the background, so a slow origin never becomes a slow response for your users.
Skip a database table entirely and track each visitor's recently viewed products with a Redis sorted set instead.
chunk() can silently skip or duplicate rows when you update data mid-loop. Here is when to reach for chunkById() instead.
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.
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.