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 2008 Forums
 Transact-SQL (2008)
 Performance question

Author  Topic 

wki3
Starting Member

1 Post

Posted - 2010-07-21 : 14:17:20
I have a stored procedure that selects data from a view like 'SELECT somestuff FROM myview'.
Would performance be any better if the procedure was written:
'Select somestuff FROM (SELECT somestuff FROM atable)'

My example is over simplified and seems silly. The actual view selects average, max, and min values from grouped data, and the stored procedure gets those values for one group using parameters.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-07-21 : 14:32:06
There is no performance benefit to using a derived table instead of a view. You can compare the two methods by checking their execution plans and doing so in the same batch. You should notice that each is taking 50% of the batch.

There could be a performance benefit of using a view instead of a derived table if the view is an indexed view. But that's a whole 'nother topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -