Laravel chunk() vs cursor() vs lazy() — Handle Large Data Without Crashing Your Server

TL;DR AI
2 min readKey summary
The article compares Laravel's chunk(), chunkById(), cursor(), and lazy() for processing large datasets safely.
It shows why loading everything with all() can exhaust memory or crash long-running jobs.
Each method fits a different use case: batch updates, read-only exports, eager loading, or simple iteration.
Choosing the right approach helps avoid memory exhaustion and Apache timeout issues in large jobs like CSV exports.
