Performance optimization for export chunks: Using cursor pagination #3502
julienarcin
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
AppendQueryToSheet Job (and queued chunk exports ) will disappear in the next major release (in favor of normal queued exports) so I think it's better to have another look at this when other things under the hood have changed first. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
It seems that the chunk exports are using the MySQL OFFSET feature.
It can have a performance cost on big exports, since MySQL needs to go through all records internally to offset the results.
That's why Laravel introduced the concept of cursor pagination: https://laravel.com/docs/8.x/pagination#cursor-pagination
In Maatwebsite\Excel\Jobs\AppendQueryToSheet:
The forPage method is calling the query builder under the hood (Illuminate\Database\Query\Builder)
I think we don't need to know the number of pages, we only need to keep the current cursor in the AppendQueryToSheet class, and dispatch jobs using cursors in the Maatwebsite\Excel\QueuedWriter class.
Let me know your thought about this.
Beta Was this translation helpful? Give feedback.
All reactions