• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

What is it about CFFUNCTION that slows things down???

Engaged ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

I have some code that imports the contents of an Excel spreadsheet into my database, during the import process I also do a fair amount of data massaging. When I run this code straight from a URL it completes in about 90 seconds. When I encapsulate the exact same code into a CFC function and call it from my Flex application the run time jumps to around 10 minutes. Is there something about calling a CFC function from within Flex that I am missing here? The only differences in the code are a few passed in variables (which are hard coded in the URL version) and the CFFunction tags. The differences are trivial so I don't see how they could be accounting for the extra time.
Any thoughts on why the CFC runs so much slower than the CFM??? Oh... I am running CF 7.02 and my client will be on that platform for the foreseeable future.

Have an Ordinary Day...
KomputerMan ~|:-)
TOPICS
Advanced techniques

Views

498

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

You didn't do a valid test. Write a simple cold fusion page that invokes the function. If it takes 10 minutes, it's the function. If it takes 90 seconds it's something else.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

I think it is something to do with how the end of the function processes. I am able to watch the records get wrote into my database table. From the time the last record gets wrote to the time the end of the function is processed is about 19 seconds for 500 records. That time goes up when more records are processed too. Here is the code at the end of my loop that processes the data prior to the end of the function. When the /CFLOOP is reached is when the last record is wrote to the table.

<CFSILENT>
<!--- bunch of code to import a spreadsheet and put it into a temporary database table so the data can be further manipulated. This is then followed by a bunch of code to do summations, groupings, create referential integrity, etc… and then put the clean data into a good data table and the bad data into a bad data table. --->
<CFTRANSACTION>
<cftry>
<CFLOOP QUERY="GetData">
<cftransaction action = "commit"/>
</CFLOOP>
<cfcatch type="database">
<cfthrow message="function = ADD records, MyFlag = #MyFlag# #cfcatch.Message# #cfcatch.Detail#">
</cfcatch>
</cftry>
</CFTRANSACTION>

<!--- here is where I start my stop watch when the record count in my table quits incrementing --->

</CFSILENT>
<CFSET MyReturnString = GoodCnt & ',' & BadCnt1 & ',' & BadCnt2 & ',' & BadCnt3>

<CFRETURN MyReturnString>
</CFFUNCTION>

I have been playing with adding a CFTRANSACTION into the code to see if that helps or hurts. So far it has not made a difference. Bottom line is after the data is processed the function is not returning to Flex in a timely manner.

Have an Ordinary Day...
KomputerMan ~|:-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

What does this do?
<CFLOOP QUERY="GetData">
<cftransaction action = "commit"/>
</CFLOOP>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

Here is the code for the entire CFC. Basically it just imports data from a spreadsheet, dumps that data into a temp table, and then processes the data that was put into a temp table. If the data is good it goes into a good table, if bad into a bad data table. The function then returns the number of records processed and a count of the types of errors that were encountered so the person can fix those bad records from within the Flex application.


Have an Ordinary Day...
KomputerMan ~|:-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2008 May 14, 2008

Copy link to clipboard

Copied

LATEST
Quick thing off the top of my head, you should set default values for some of those variables, then change it when necessary. This would cut down on a top of try/catch processing and a lot of conditional parsing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation