October 15, 2008 at 7:16 am
What is difference bwtween Inline Table-values Function and Multi-statement Table-vlued Function?
My function result is fix. it is only one row with 5 column.
I need it frequently.
which function should i use in above situation. which function use less memory?
October 15, 2008 at 8:34 am
An inline function only allows a single select statement as the function body. When run, the optimiser will treat it like a subquery.
multi-statement functions allow a number of statements inside, allowing more complex processing. However they tend to perform very badly.
See - http://sqlinthewild.co.za/index.php/2008/08/12/views-or-functions/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 15, 2008 at 8:40 am
It really depends on how you're going to use the information. Since it's only a single row returned, probably, you won't have issues with either approach. Usually, the inline is recommended over the multi-statement table valued function. I wrote up some tests and posted them here[/url]. Gail posted an even better discussion and example here[/url]. And there was a discussion around all this just recently here at SQL Server Central.
Hopefully one, or all, of those will help.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 15, 2008 at 8:41 am
Oops. There I am typing up the response and looking for your URL and there you are posting it. Ah well. Reinforces the point.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 15, 2008 at 8:52 am
Grant Fritchey (10/15/2008)
Oops. There I am typing up the response and looking for your URL and there you are posting it. Ah well. Reinforces the point.
😀
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 16, 2008 at 4:06 am
If the output is fixed and you don't need to pass any parameter, consider VIEWS.
-- CK
October 18, 2008 at 3:28 am
Seems to be continued here: http://www.sqlservercentral.com/Forums/Topic588073-146-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 18, 2008 at 4:00 am
Thanks for the valueable reply.
My requirement is to call this function approximately 2000 times in a hour from front end system, will it serve purpose, or still i need look at something else? (This function has simple Select statement fetched values from table having data not more than 1000 rows)
October 18, 2008 at 9:31 am
Pravin Patel (10/18/2008)
Thanks for the valueable reply.My requirement is to call this function approximately 2000 times in a hour from front end system, will it serve purpose, or still i need look at something else? (This function has simple Select statement fetched values from table having data not more than 1000 rows)
Then, it should probably not be a function at all. It should probably be a stored proc or perhaps a view.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 18, 2008 at 11:36 am
Jeff Moden (10/18/2008)
Then, it should probably not be a function at all. It should probably be a stored proc or perhaps a view.
Probably.
I think at this point we need to see either code for this function, or detailed requirements, as right now we're just going round in circles getting nowhere.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply