Problem/Motivation
This ticket is in response to #2888446: View too large for default php session timout. We need a better way to export large data sets. Currently, if the view is large you will likely hit a php timeout and even updating this value might not be enough as there are mysql timeouts as well.
Proposed resolution
While updating the php/mysql timeout value is a possible solution, a better solution would be to leverage the batch api to write to a file on the server.
Remaining tasks
- determine how to do this OOPHP.
I am trying to use this as opportunity to learn rather than have someone else go and do it. Some open questions are
- how best can we leverage the CsvEncoder class? Is this simply extending the class and overriding the encode method?
- CsvEncoder includes an event, should I create another custom event that calls batch api()?
Comments
Comment #2
robpowellComment #3
robpowellComment #4
robpowellGlad to see #2888446: View too large for default php session timout was closed. Would love to start work on this, we discuss the approach for this?
Comment #5
grasmash CreditAttribution: grasmash commentedI did a little performance testing. I found that very little time was spent actually serializing the data, most of the resource consumption is done by views attempting to render entities and fields. I managed to improve the performance dramatically by making these changes to my view:
This allows me to render a view with 2000 rows in approximately 3 seconds.
Comment #6
grasmash CreditAttribution: grasmash commentedSince this module is not responsible for the bottleneck, implementing the batch API isn't an effective solution. The performance issue needs to be resolved via views configuration or else some modification to the rendering process in core. Batching the serialization isn't going to help things.
Comment #7
FatherShawnI have a view of user_field_data that also joins with three other tables - about 3,000 rows. Setting all the fields to raw it still dies when I try to export via CSV. Any other suggestions before I begin to dig into why?
Comment #8
grasmash CreditAttribution: grasmash commentedYou might need to modify your PHP settings by increasing memory limits or execution time.
You might also consider generating two separate CSVs, one for rows zero through 1501 for rows 1500 and onward.