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
 General SQL Server Forums
 New to SQL Server Programming
 Views

Author  Topic 

Rainmann
Starting Member

5 Posts

Posted - 2011-08-15 : 15:04:39
I have created a complex view that gives me all the data I want, but it performs horribly. I cannot create indexes over the view due to using outer joins and subqueries.

What I'm trying to figure out is, am I using the wrong tool for the job? When should a view be used?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-08-15 : 15:09:58
It's hard to say without seeing the code. It would help if you posted it.

Also, do you need to select all the data the view provides, or just a subset? In that case, a stored procedure may be a better option (parameter passing in particular). Do you need to join the results of the view to other data?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-15 : 15:23:13
Whatever indexes you planned on adding to the view, just add them to the base tables instead.

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 -