2026-03-12 · 7 min read
A Practical Laravel Query Performance Checklist
How I approach slow endpoints: measure first, then fix the right layer—indexes, N+1 calls, and transaction scope.
When an endpoint feels slow, the first mistake is optimizing before measuring. I start by capturing what is slow: SQL time vs application time vs external IO.
1. Confirm the database is the bottleneck
Use query logs or profiling hooks to list the top queries by total time. If the database dominates, stay there until it is honest.
2. Kill N+1 queries with intent
Eager loading is not “free.” I load relationships that the response actually needs, and I avoid accidentally hydrating large graphs.
$users = User::query()
->with(['profile:id,user_id,bio'])
->paginate(25);
3. Indexing is a product decision
Indexes speed reads and tax writes. I align indexes with real access patterns: filters, joins, and order-by clauses that appear in hot paths.
4. Watch transaction boundaries
Long transactions pin resources. I keep transactional scope tight and move optional work to queues when it is safe.
5. Validate with before/after numbers
The goal is predictable latency under load—not a refactor that looks clever on paper.