5 Replies Latest reply on May 14, 2008 2:16 PM by iKnowKungFoo

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

    KomputerMan.com Level 1
      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 ~|:-)
        • 1. Re: What is it about CFFUNCTION that slows things down???
          Dan Bracuk Level 5
          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.
          • 2. Re: What is it about CFFUNCTION that slows things down???
            KomputerMan.com Level 1
            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 ~|:-)
            • 3. Re: What is it about CFFUNCTION that slows things down???
              Dan Bracuk Level 5
              What does this do?
              <CFLOOP QUERY="GetData">
              <cftransaction action = "commit"/>
              </CFLOOP>
              • 4. What is it about CFFUNCTION that slows things down???
                KomputerMan.com Level 1
                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 ~|:-)
                • 5. Re: What is it about CFFUNCTION that slows things down???
                  iKnowKungFoo Level 1
                  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.