Spreadsheet output sort of working BUT...
I have the output for the spreadsheet working, and it works fine for regular tables, but when there are custom fields and the result set is large, the process takes so long it just ends up timing out.
I'm already disposing of each object once I've finished with it; this solves the out-of-memory errors I was initially seeing, and if I run top on Lettuce, I don't see any inordinate memory usage from my script. However, with a large record set result (my test has 307 hits, and is showing a set of four regular and six custom fields), the process inevitably times out; sometimes I get an error, and sometimes an incomplete file.
As always, the cost of supporting custom fields proves to be insanely large. I'm thinking that it might be possible to reduce the overall timing and memory requirements of the operation in these ways:
- Instead of storing all the results in a single variable and then sending them out in one go, I can echo them steadily out, which would reduce some of the memory load and keep the connection alive. This gives me an incomplete file when the request times out, but what I have up to that point is good.
- Instead of doing the full query to fill the initial dataset, I could do a simpler query to get back just the id numbers of the hits, and then do a separate MdhRecord operation to fill and output each record separately. Combined with the above, we'd then have a long sequence of separate operations rather than one big one.
- I could investigate the possibility that PHP has support for streaming, and use a stream class to output my data.