Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ladybirdweb's avatar

Laravel Excel export with 100,000 records

We are using Laravel Excel 2.1. I am trying to export 100,000 records from database from different tables to one excel sheet.

First, we kept export all the records in one job by picking data in chunks from database but that took long enough for job to get timed out.

Second, we export 1000 records in the first job and as the job ended we created another job which appended next 1000 records. But this gave us a weird problem that running php artisan queue:work database on terminal gets exists automatically without giving any warning after processing some jobs.

Something like this :

➜  faveo-helpdesk-advance git:(73999b9d2) ✗ php artisan queue:work database --tries=5
[2018-11-02 03:07:51][1333] Processing: App\FaveoReport\Jobs\ManagementReportExportJob
[2018-11-02 03:08:09][1333] Processed:  App\FaveoReport\Jobs\ManagementReportExportJob
[2018-11-02 03:08:15][1334] Processing: App\FaveoReport\Jobs\ManagementReportExportJob
[2018-11-02 03:08:33][1334] Processed:  App\FaveoReport\Jobs\ManagementReportExportJob
[2018-11-02 03:08:39][1335] Processing: App\FaveoReport\Jobs\ManagementReportExportJob
[2018-11-02 03:09:00][1335] Processed:  App\FaveoReport\Jobs\ManagementReportExportJob
➜  faveo-helpdesk-advance git:(73999b9d2) ✗

What I feel is, in the second approach it has to load the file multiple times in the memory to append to it (using Excel::load() method of Laravel Excel), which is not efficient.

And In the first approach, a single job has be keep running for a long amount of time.

It will be great If I can get help on how to tackle this situation.

0 likes
1 reply

Please or to participate in this conversation.