So, as my title says, I have a ColdFusion program that used to take 10 minutes to run on our server but now runs in <15 seconds. Being confused why such a simple program was taking 10 minutes me and my boss examined it to figure out the culprit section of code causing the slow down. We ended up making it go from 10 minutes to 5-10 seconds to run.
Now we're not sure why the fix is a fix, so we were wanting to see if anyone could explain to us why/how this works so that we may understand the fix so we might be able to utilize the speed up within other programs.
The beginning of this program is a query that grabs ~4800 records (nothing outrageous), We then loop through these records, which we figured out was the slow section. Here's a rough example of what we had, and what we did to fix it. TextString is set at the top near the query to headers of the fields we're returning .
Old Code:
<cfloop>
<CFSET TextString = TextString & DriverID & TabChar & LocalSSN & TabChar & FirstName & CarriageReturn & LineFeed>
</cfloop>
Fixed Code:
<cfloop>
<CFSET LocalTextString = "">
<CFSET LocalTextString = LocalTextString & DriverID & TabChar & LocalSSN & TabChar & FirstName & CarriageReturn & LineFeed>
<CFSET TextString = TextString & LocalTextString>
</cfloop>