# Performance

Entries tagged with "Performance".

Hidden Methods Intermediate

Number::pairs()

Split a numeric range into evenly sized chunks as start/end pairs — great for batch processing and pagination math.

Performance Helpers
Hidden Methods Beginner

The once() Helper

Memoize the result of an expensive expression so it only executes once per request, no matter how many times it is called.

Performance Helpers
Eloquent Secrets Advanced

DB::whenQueryingForLongerThan()

Get notified when your cumulative database query time exceeds a threshold during a single request.

Database Performance Debugging
Unknown Classes Beginner

Benchmark::dd()

Time one or more closures and dump the results — the quickest way to compare performance of different approaches.

Performance Debugging
Blade Tricks Intermediate

The @persist Blade Directive

Keep a DOM element alive across Livewire page navigations — prevent re-rendering of video players, maps, or complex widgets.

Performance Helpers
Unknown Classes Intermediate

Cache::flexible()

Serve stale cache immediately while refreshing in the background — the stale-while-revalidate pattern built into Laravel.

Performance Caching
Eloquent Secrets Intermediate

Model::withAggregate()

Load aggregated values from related models as attributes — count, sum, min, max, avg — in a single query without loading the relation.

Database Performance