Skip to main content
Inspiring
August 30, 2008
Question

CFC seems very slow

  • August 30, 2008
  • 3 replies
  • 606 views
Hi all,

I have a cfc which checks some details from a couple of database tables then inserts submitted form data to a database.

When the form is submitted, it is validated server side, then if it passes validation the CFC is called to check some values and insert the data.

I have ruled out validation taking time, so it is somewhere in the cfc.

I have included the CFC below. Any suggestions would be welcome.

TIA,
Paul

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    August 31, 2008
    Here are two suggestions, besides those Dan and PaulH have mentioned.

    1) Remove the session lock. There is apparently no need for it. It is like some unemployed guy noboby knows who just stands there, playing doorman and blocking the way.

    2) It is almost never the job of a function to redirect. Instead, move the cflocation tag to the page(s) that call the function add(). Create an object, use it to call the function and, based on the result, do a cflocation.



    Inspiring
    August 30, 2008
    Outside5.com wrote:
    > I have included the CFC below. Any suggestions would be welcome.

    you haven't var scoped any of your variables, under a load this thing will start
    stepping all over itself. you need to fix this immediately.

    as dan suggested, how are you calling this thing that it sees the form & CGI
    scope? also cflocation in a CFC wouldn't be considered kosher by most folks.

    there is/was a "bug" in cfswitch that slows things down when the case vars
    aren't numeric. you'd be better off using 1,2,3 instead of "first", second",
    "third".

    Inspiring
    August 30, 2008
    You sure that cfc doesn't just crash on the first line where it is looking for the form scope?

    The queries where you select the entire table could be slowing you down if the tables are big. You are also likely to experience logic problems because of that.

    In any event, comment out the cflocation tag at the end and look at your de-bugging info. It will tell you how long the cfc took and how long each query took.

    To get more details, cfdump some gettickcounts at various stages of your function to see what part is taking so long.
    Inspiring
    August 31, 2008
    Thanks for your replies.
    I think I have got to the bottom of it. There is an email being sent as a part of the process and when commenting out the email the script runs smoothly.

    I have tried also moving the email to the foot of the thank you page, but this seems to bring the delay back. Is there a way around this as the email is necessary for the process.

    Thanks,
    Paul