02-28-03, 13:59 #1Registered User
- Join Date
- Feb 2003
Unanswered: Performance question: View vs. Table
Hi all, I am new to the forum~
Suppose I have multiple tables, T1, T2, T3. I will use SELECT queries and apply AVG() and STDEV() on each of their columns, and average their results.
I can do this in two ways: one is to apply my SELECT multiple (3) times, then divide it by 3 in this case.
Another way is I create a View that UNIONS all T1 T2 T3, and apply AVG() and STDEV() on each columns.
Which solution is better? I mean, from a performance point of view. This is just a simplified version of my problem, and I would like to know what is the performance of using one (View) over the other (Table)... Does using View instead of table give me any performance overhead? Thanks everyone...
02-28-03, 16:41 #2Registered User
- Join Date
- Feb 2002
- Houston, TX
They are the same solution. whether you use a select statment or a veiw you will be pulling data off the drives (or cache) to produce the answer. The view has the advantage of being pr-optimized. Views are generally used for this type of thing as it hides all the aggregation.
Don't know if this helped, Books Online has some interesting info look up views-SQL Server, overview and follow the hyper link to Scenarios for Using Views.Paul Young
(Knowledge is power! Get some!)