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 - are they precompiled?

Author  Topic 

liptonIcedTea
Starting Member

26 Posts

Posted - 2008-06-12 : 20:35:12
Hi,

I have a search screen at the moment, and what it does is it calls a view listing all of the entries and then filters out based on the search criterias.

My question is... is that the most efficent way of doing things? If views are virtual tables, does that mean they already exist or does the database have to create the view each time it is called?



LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2008-06-13 : 01:48:21
Standard views are just convenient ways of storing useful or complicated select statements. There are no real performance benefits one way or another. It is your query that gets compiled and the contents of the view is incorporated into the query before the plan is worked out.
A word of warning with views as well - don't expect sorting a view to be reflected in your output. Always put the order by in the select.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-13 : 02:06:51
You can have materialized view, aka indexed views.
It's a fairly complicated process (21 steps to consider).



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -