Quantcast
Viewing all articles
Browse latest Browse all 15889

how server can establish a query plan for a view as soon as the view is saved.?

based on the following MSDN ,it is say"A database server can establish a query plan for a view as soon as the view is saved."

"Query plan generation   A query plan is an internal strategy by which a database server tries to create result sets quickly. A database server can establish a query plan for a view as soon as the view is saved.For a query, however, a database server cannot establish a query plan until the query is actually run — that is, until the user explicitly demands the result set."

http://msdn.microsoft.com/en-us/library/h1w1kty9(v=VS.90).aspx

I used the following script to create a view

USE [AdventureWorks2008R2]
GO

CREATE VIEW  [dbo].[view1]
AS
Select * FROM [Production].[Product] Where [ProductNumber]='FR-R72R-48'
GO

but I didn't see the query plan after running the above script.

seLECT usecounts, cacheobjtype, objtype, [text]  ,P.refcounts
 FROM sys.dm_exec_cached_plans P 
         CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
 WHERE cacheobjtype = 'Compiled Plan'    AND [text] NOT LIKE '%dm_exec_cached_plans%';




Viewing all articles
Browse latest Browse all 15889

Trending Articles