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)
 Caching views?

Author  Topic 

tech_1
Posting Yak Master

129 Posts

Posted - 2011-09-07 : 06:13:40
if you have a view - is it cached? or does it have to generate the view everytime?
what about a view with a column which has a call to a function that does something - does that get called for every row everytime or does it cache the results?

Lewie
Starting Member

42 Posts

Posted - 2011-09-07 : 07:09:14
My understanding is that your results are cached in RAM for a period until the cache is need for something else.To clear your cache DBCC DROPCLEANBUFFERS
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-07 : 10:19:01
My understanding is:

A View is not cached.

The function will only be executed if that Column, in the View definition, is actually used in the Query that references the View.

Same with JOIN'd tables ... only become part of the actual query if they are needed for the columns that are actually used - i.e. the optimiser will detect unused tables and ignore them - well, I expect its not going to get it right every time in complex scenarios ...

If the view is Indexed then the data will be materialized to be stored in the Index - so similar to how you envisage it being cached
Go to Top of Page
   

- Advertisement -