Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 performance difference between Query and View

Author  Topic 

Abdul Jabbar
Starting Member

1 Post

Posted - 2008-07-10 : 09:45:16
Can anybody help to find the performance difference between Query and View.

What is the performance difference when "where " clause is used with Query and the View which is using the same query.


Actually i've written a large query in a view which fetches almost 1million records.

and if I apply filters to that query then that fetches 10,000 records.

my question is that if i apply the same filters to that view
then what will be the scenario
whether after filtering the view
i.e.
select * from vwProducts
where producttypeid = 10

will fetch 1million records first and then it will filter down the to 10,000 records.
if this is the case then the performance of the view should not be good.

So what will be the case.

Which one will be faster.

Thanx in advance.

AJ

MakeYourDaddyProud

184 Posts

Posted - 2008-07-10 : 09:59:10
It depends on the complexity of the view. If you can get away with a view that has its own select criteria then yes, because the query plans for the view are compiled such that when the view is invoked, this step is not necessary.

With direct SQL, the query optimiser has no such compiled plan available, and as such will take slighly longer to run.

Supplemental to the query and the view are statistics/heuristics, but this is another story...

>>>>> THE Whammy Bar String Trasher <<<<<
Go to Top of Page
   

- Advertisement -