Does anyone have any experience when SQL Server 2008 R2 can automatically match an indexed view (also known as materialized views) that contains joins to the query?
For example, a view
select dbo.Orders.Date, dbo.OrderDetails.ProductID
from dbo.OrderDetails
join dbo.Orders on dbo.OrderDetails.OrderID = dbo.Orders.ID
It is not possible to automatically match the exact same query. When I select directly from this view with (noexpand), I actually get a much faster query plan that checks the clustered index of the indexed view. Can I get SQL Server to do this automatically? I have quite a few queries and views, and I don’t want to refer to the indexed view manually every time because I use OR matching.
I am on a corporate version of SQL Server 2008 R2.
Edit: I found a solution. SQL Server 2008 R2 does not match indexed views with more than two joins automatically. This will probably slow down the optimization process too much.
2: 2 , , , . - , .
, :