UDF's vs Props

  • Greetings all.

    I have quite a few procs which exec other procs to do away with rewriting code.

    I am (was) quite happy with the speed at which they ran.

    I then started playing with UDF's. I found, what I think to be unrealistic, improvement in speed.

    Example:

    A proc accepts 2 values, one of which is an output. It does an index search on a table with about 25000 rows and returns the found record. It's a distinct select.

    I then made a function which does exactly the same.

    Running these two in a loop (Seperate loops) 100 times was what surprised me.

    The proc too about 1700ms to run 100 times. The function however only took 30ms to run 100 times. Is this correct?

    I timed it by getting the date (GetDate()) before the loop started then again when complete and doing a dateDiff on the two values.

    Am I missing something?

    I want to convert all the procs I exec to functions. Should I beware of something?

    I have not found anything saying UDF's are evil.

    Thanks!

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply