Excel can have a maximum of just over 1 million rows, so you cannot add 5 million rows to it. (the max is 1,048,576 rows I believe)
Jan 11, 2023
7
Level 2
My eloquent query is getting failed for rows over 5 Million
I am running a background job to export the rows.
My query is
$chain = [];
$loop = 0;
Submission::with(['referredBy', 'referredTo'])
->where('project_id', $this->project->id)
->orderBy('position', 'asc')
->chunk(64000, function ($submissions) use (&$loop, &$chain) {
// Add a job to the batch for each chunk of submissions
// logger('chunk: ' . $loop);
$keys = $submissions->pluck('id');
$chain[] = new ExportSubmissionsFastExcel($this->waitlist, $keys, true, $this->uniqueKey, $loop);
$loop++;
});
// logger('chain: ' . count($chain));
Bus::batch($chain)->then(function (Batch $batch) {
// all jobs finished successfully...
})->catch(function (Batch $batch, Throwable $e) {
// First batch job failure detected...
// logger('one of the jobs in the batch failed...');
})->finally(function (Batch $batch) {
// The batch has finished executing...
// logger('the batch finished executing...');
})->name($this->batchName)->onQueue('export')->dispatch();
How do I optimize it?
Please or to participate in this conversation.