I just joined a project, and have been going over the code. We need to export a lot of data out to Excel for our internal users. There are roughly 5 people who would have access to this functionality at a given time. In order to output to Excel, here's what I found:
- retrieve data from DB, store in $_SESSION
show HTML page view of data
when the user wants to export
- retrieve the DB data from $_SESSION
- create a string in memory of a CSV
- print the HTTP Headers with Excel as the filetype
- print out the CSV formatted strings
This storage in $_SESSION is happening even when the user is not going to export. This strikes me as terribly inefficient, since the $_SESSION variable could explode in size, since each of the DB table retrievals can be up to 30MB per table, and the expiration on $_SESSION is set to 24 hours. So potentially, there could up to 5 users in the system, with up to 150MB $_SESSION variables. Sound about right?
Has anyone else ever seen something like this? Is this like a bootleg Memcache? Wouldn't it be best to just write the data to a flat-file that's updated once every few hours?