January 15, 2012 at 11:58 pm
hi,
Does Table Value function caches execution plan?
one of my query is performing slow for the first time. i can't put this query in stored proc as it is getting called from Tableau.
but i can put this in Table Value function and call from Tableau.
My question Does Table Value function caches execution plan? so that i can gain performance?
Thanks,
Ami
January 16, 2012 at 1:49 am
Inline table valued funtion or multi-statement table valued function?
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
January 16, 2012 at 2:28 am
does it make a difference?
it is multi-statement table valued function
Thanks,
Regards,
Ami
January 16, 2012 at 2:40 am
Yes it does make a difference, if it didn't I wouldn't have asked.
Multi-statement table valued functions do cache execution plans, they're treated more like procedures. That said, they have performance problems of their own coming from their use of table variables for output.
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
January 17, 2012 at 5:08 am
The cached plan only saves you recompile time for performance. A multi-statement table valued function is only good for working with very small data sets. This is because, as Gail points out, it uses table variables. Table variables have no statistics. This lack of stats makes them very poor performers depending on what your'e doing with it.
"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
January 17, 2012 at 9:31 pm
thanks Fritchey,
small set of value means may i take it as less than 100 rows or 500-1000 rows?
with the current execution plan can i force sql server to make use of the hints?
so that the first time itself i can get the performance?
thanks,
ami
January 18, 2012 at 3:51 am
Anamika (1/17/2012)
thanks Fritchey,small set of value means may i take it as less than 100 rows or 500-1000 rows?
Sometimes even 1 row is too many.
with the current execution plan can i force sql server to make use of the hints?
so that the first time itself i can get the performance?
What hints?
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
January 18, 2012 at 4:02 am
hints to make use of particular indexes
January 18, 2012 at 4:12 am
And why do you think that hints will
1) Make the first execution faster?
2) Be better than what the optimiser comes up with itself?
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
January 18, 2012 at 4:15 am
You're looking at a 500+ rows in a multi-statement UDF and you've got index hints inside the queries? I think you're digging a very deep hole. Hints should be used in very few situations. If you have multiple hints inside this query I think you're way off on the wrong track. And no, I wouldn't trust the UDF with 500+ rows.
"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
January 18, 2012 at 8:13 am
Anamika (1/15/2012)
hi,Does Table Value function caches execution plan?
one of my query is performing slow for the first time. i can't put this query in stored proc as it is getting called from Tableau.
but i can put this in Table Value function and call from Tableau.
My question Does Table Value function caches execution plan? so that i can gain performance?
Thanks,
Ami
1) if it is performing slowly the FIRST time and not the SECOND+ time it could simply be a matter of doing physical IO the first pass to get the data off disk and into RAM.
2) You should absolutely get rid of your multistatement UDF. They are death from a performance standpoint.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply