SQL Server Performance

Views as a substitue for a UDF?

Discussion in 'T-SQL Performance Tuning for Developers' started by hominamad, Nov 21, 2003.

  1. hominamad Member

    Question for everyone: We have a UDF which returns a table. In the past we were doing join's in our procs directly with the UDF and noticed some performance hits. Then we started inserting the results from the UDF into a temptable and doing the join with that. I'm still not confident it's working any better.

    How about creating a view which will give us the table that the UDF was returning, and then doing a join with the view - thereby eliminating the UDF altogether?

    What is considered best practices for these types of operations? Code readablity is nice, but of course performance is concern #1.


  2. satya Moderator

    Have you checked thru books online for such information between UDFs & Views.

    Satya SKJ
  3. FrankKalis Moderator

    AFAIK a UDF is not a true set based approach, but rather some kind of row by row processing.
    If you have the opportunity to use a view (or a temp table), I would almost always use this. Especially when you have to deal with large resultsets.


Share This Page