• Dave Ballantyne (7/2/2009)


    Scalar udfs are generally quite slow and should be avoided.

    Try to isolated the issue , what is performance like if you make it a sequential count ?

    Also i notice that code is used is the clustered primary key , it could be page splitting on the inserts ?

    Ouch, you can pretty much be sure there are page splits happening in a million row insert.

    Like Gail has said, without knowing what the code is in the function there really isn't a way to make it faster because the UDF will still run a million times.

    Can you at least give us some pseudocode for the UDF like:

    Take the second parameter passed in

    Loop through it by character, multiplying the the ASCII Code by the first parameter and if > 255 substract 255 and place that character in the 10 character string.