Closed okmkey45 closed 3 years ago
Every query has to reopen the spreadsheet file which takes PhpSpreadsheet some time, so indeed gets longer every append.
I've got some changes planned for 3.2 that will improve this.
I'm experiencing the same issue here. The file sizes aren't massive either, only 5-10mb. I'm not experiencing any spikes in CPU or Memory usage.
I decided to build a service with python and pandas and it improved a lot, and I mean A LOT. Laravel Excel is an excellent library but I guess for this job maybe it's not the right tool
@okmkey45 To be fair, it's not really Laravel Excel's fault, it relies on PHPSpreadsheet which is an inefficient library for reading/writing files. It's a shame because the abstractions around chunking queries and queueing jobs are really handy here, and save me a lot of time writing a service in Go/Python and hooking it up with my queue.
There are quite a few alternatives to PHPSpreadsheet which are much faster on large files, maybe they could be swapped in when we use ->queue
or ShouldQueue
?
@aakarim that's actually something I've consider, but currently don't have the time or use-case to implement this. I would be open for a PR as long as it would be kept simple and opt-in.
I'll have a bash after this deadline. Are there any packages you prefer/recommend @patrickbrouwers? https://github.com/box/spout seems like a good place to start.
@aakarim yes box/spout. I have even consider to make it possible to use league/csv if you just want csv, that's by far the fastest option for large bulk imports/exports.
This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.
@aakarim I created a Laravel project https://github.com/vitorccs/laravel-csv/ inspired on Laravel-Excel and implementing some cool stuffs like FromQuery, WithMapping, WithHeadings, etc.
E.g: the export of a 50k records CSV file dropped from about 45min to 10min
Hope this can be useful for anyone reading this issue report.
That looks good @vitorccs but unfortunately my use case is mostly XLSX.
In the end I switched to a custom Go system to process my Excel exports for anything with over 2,500 rows. It was less work overall than modifying this library.
Prerequisites
Versions
Description
I have been using this package over a year now. Recently I started to have problems with memory and performance. Users are trying to download a lot of data; some times historic data. So I read the docs and I found the queued section. At first, it was the perfect solution. With queued exports, multiple jobs are dispatched in order to generate the file by chunks. But I noticed something. Each job (AppendQueryToSheet) that was dispatched took more time to finish than the last one. And the final job (CloseSheet) took even more time to finish.
My question is: ¿is this the way that queued export works? ¿or am I missing something?
Additional Information
I am using Redis and Horizon. Even I tried with multiple workers but it seems that everytime a job finishes, a new job is dispatched. So, it did not solve my problem.
I attached this image so you can see times registered.