Forum Moderators: open
So I was wondering whether it might be worthwhile to create a View of all that - a View which joins all the tables in a typical way. Then my Stored Procedures, instead of Joining Joining Joining, can just do their selection from that View.
My question: Does a View make my query more efficient? If the View is somehow pre-rolled, pre-joined and waiting for a simple SELECT WHERE query, or does the View do the joining at the time it is being accessed?
Any suggestions as to the proper and intelligent use of Views to facilitate complex INNER JOINed queries?
For simple inner joins, my experience is that the performance gain (if any) will be minimal at best, since you really only gain the time it takes for the query optimizer to do its job, which is usually insignificant in relation to the time needed for actual lookup and retrieval of data.
If you find that every query involves multiple table joins, you might consider doing some degree of denormalizing to speed up frequently executed queries.
The problem is, there are very strict requirement when creating such a view. Do a search for "SQL Server indexed views" and you will get a lot of results explaining them... In some cases, they can increase the performance quite a bit, but this comes with some effort and some changes to the db.
Views are nearly always the entities you identified during logical design (if you did one!). Indexed views are usually done after first release for optimisation.