Results 1 to 2 of 2
  1. #1
    manik's Avatar
    manik is online now Om Shanti!
    Join Date
    Apr 2008
    Location
    Boston, USA
    Posts
    13,175
    Thanks
    744
    Thanked 699 Times in 550 Posts
    Blog Entries
    4
    Feedback Score
    4 (100%)

    Default Inline and Multi-Statement Table Valued Function Performance Comparison

    Inline and Multi-Statement Table Valued Function Performance Comparison

    In summary Inline is preferred over multi-valued functions when dealing with large tables. Recently I was working on a similar case on a project. Changing the multi-statement function to inline gave me a big performance boost; reduced the execution time from 30 second to less then a second for the original stored procedure.

    This is a great comment explaining the internals of the performance comparison (stackoverflow):

    Internally SQL Server treats an inline table valued function more like it would do for a view and treats a multi-statement table valued function similar to how it would a stored procedure.

    When an inline table-valued function is used as part of an outer query, the query processor expands the UDF definition and generates an execution plan that accesses the underlying objects, using the indexes on these objects.


    For a multi-statement table valued function, an execution plan is created for the function itself and stored in the execution plan cache (once the function has been executed the first time). If multi-statement table valued functions are used as part of larger queries then the optimiser does not know what the function returns, and so makes some standard assumptions - in effect it assumes that the function will return a single row, and that the returns of the function will be accessed by using a table scan against a table with a single row.

    When the performance becomes an issue
    Where multi-statement table valued functions can perform poorly is when they return a large number of rows and are joined against in outer queries. The performance issues are primarily down to the fact that the optimiser will produce a plan assuming that a single row is returned, which will not necessarily be the most appropriate plan.
    Free Classified Ads & BUSINESS/PROFESSIONAL SOCIAL NETWORK


  2. #2
    naoki is offline Senior
    Join Date
    May 2011
    Posts
    630
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Feedback Score
    0

    Default

    hmm.. nice info! thanks for sharing!

Similar Threads

  1. Is Twitter valued in SEO World?
    By stephanramies312 in forum Search Engine Optimization
    Replies: 4
    Last Post: 07-17-2011, 09:45 AM
  2. tr {display: inline-table;} in IE
    By stefanpralka in forum CSS
    Replies: 1
    Last Post: 03-23-2011, 03:06 AM
  3. Comparison of the dav tags nad table tags in HTML
    By deveshraigniit in forum HTML / DHTML
    Replies: 3
    Last Post: 03-22-2011, 08:48 AM
  4. Thesis Theme Bonus valued at $ 477
    By tableboy in forum Marketplace - Buy, Sell & Trade
    Replies: 0
    Last Post: 05-05-2010, 11:40 AM
  5. Real Valued Adsense Top Paying Keywords
    By cybermoney in forum Search Engines
    Replies: 3
    Last Post: 04-14-2010, 09:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Partners: BOSTON WEB DEVELOPER, LLC   |   WEBCOSMO CLASSIFIEDS