4 responses

  1. LondonDBA
    2019-03-12

    I think there’s a copy/paste error here:

    SELECT t.N,
    dbo.SF_Test(t.N) AS ReturnValue
    INTO dbo.FunctionResults
    FROM dbo.Tally t
    CROSS APPLY dbo.ITVF_TEST(t.N) ITVF;

    No need for the CROSS APPLY to the ITVF for your SF test.

    Reply

    • Wayne Sheffield
      2019-03-13

      Thanks for responding. That is potentially affecting the performance of the Scalar UDF, so it looks like I need to redo the test. Thanks for reporting this.

      Reply

  2. Brent Leslie
    2020-06-16

    Hi Wayne, in testing this works great.

    In the real world, I often call the same UDF on multiple columns. When doing this, there seems to be a threshold for when Inlining is faster or slower, depending on the number of times it’s called in the SELECT. Call it on one column – almost always faster. But I had another one where I called it on 25 columns and it made the query dramatically slower. I guess it’s dependent on the function for where this threshold is…

    Reply

    • Wayne Sheffield
      2020-06-16

      Hi Brian,
      Okay, I’m intrigued. Can you be more specific as to what kind of function you would call on 25 columns?

      Thinking of what SQL will be doing , there will be 25 joins going on. That alone will slow things down.

      I’d love to see more information to test this out.

      Reply

Leave a Reply to let me know how you liked this post

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
mobile desktop