laravel-data-chunking-large-datasets
Installation
SKILL.md
Data Chunking for Large Datasets
Process large datasets efficiently by breaking them into manageable chunks to reduce memory consumption and improve performance.
The Problem: Memory Exhaustion
// BAD: Loading all records into memory
$users = User::all(); // Could be millions of records!
foreach ($users as $user) {
$user->sendNewsletter();
}
// BAD: Even with select, still loads everything
$emails = User::pluck('email'); // Array of millions of emails