Fairly new to Coldfusion. Running CF2021 on Windows Server 2016 Datacenter 3 cores/12GB RAM. Running SQL server 2012 (Server 2012 R2; 3 cores/12GB RAM). These are virtual servers as well. Using FW/1; MVC.
I have my code written to download a large set of data (165,000 rows with 34 columns/headers).
In my code, I have the following line started
theFile=GetDirectoryFromPath(getCurrentTemplatePath()) & "newSpreadsheet.xlsx";
which means it is saving to my "views" folder on my server (no big deal). Then I am using spreadsheetAddColumn(.....) to add my headers and spreadsheetAddRows(theSheet,#rc.myquery#); to pull my query from my model view. My problem is, there is so much data that it is pulling down, the page is erroring out with a timeout error. I limited my download to 25k records and it takes about 14 minutes to pull this set of data. I need to figure out how to get all of the records in ONE spreadsheet and what I would like to do is run a scheduledtask in order to run this during down periods and have it readily available to download the spreadsheet when folks start working. Any ideas how to speed this up and/or not have the site time out?
Another problem I am having is my scheduled tasks aren't running due to our server being secured by Siteminder. It requires a user log in upon visiting the site, even though I have anonymous authentication enabled. So my shceduled task will run, but I am getting a 403 error. I have looked into doing this via my code, but have been unsuccessful. So if anyone has any ideas on this as well, I would appreciate any suggestions.
If this is a manual request and not a scheduled task, you should post your scheduled task issue as a separate question for people to target their answers accordingly.
For security reasons, You should never create a file in a publicly accessible folder.
There are two versions in a gist here.
This code requires a
<cfquery>data set and will create a uniquely named file in the CF server's temp folder. You can pass in a list of column header names as one argument and a file name that will be used once it's created and presented to the user. You might remove the code that toggles the file extension and only createxlsxfiles. I used this in an extremely high-load financial application. We restricted data requests to 30k rows as a matter of course.The bigger problem you're facing is likely more of a database issue. How quickly does that data generate when you run the query directly in SQL Manager? Run that query with the execution plan turned on. That should help you identify bottlenecks in the query.