February 8, 2010 at 4:12 pm
Ok, I've always been under the assumption that views were terrible for performance and you should always use a tvfunction. We are starting to implement some new databases at work and the debate came up whether we should use views, tvfunctions, or both given some set of circumstances. Aside from the fact that tvfunctions are prone to bad coding, they still are quite useful and more flexible than views.
So I pose to you the following questions:
Is there a general set of rules that one should follow in order to decide whether to use a function or view? Is there a significant performance hit when inserting/updating a table which an indexed view is based off of? What is the difference in performance of an indexed view as opposed to a tvfunction that can't be indexed? What about performance of unindexed views and tvfunction?
Here is what I came up with: (This by no means has been validated by any sort of testing yet)
1. If it requires parameters that do not go directly in the where clause then use a function
2. If it requires more than a select statement to do its work then use a function
3. If 1 or 2 are not satisfied then use a view
Looking forward to hearing your answers!
Josh
February 8, 2010 at 5:02 pm
Hi
i thinki you should search for the advantages and disadvantages of the views and table-valued functions and do a comparison. Below are some sites that might help you
http://sqlserverpedia.com/wiki/Views_-_Advantages_and_Disadvantages
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply