Databases Reference
In-Depth Information
How it works...
As per BOL, the SQL Server query optimizer automatically determines when an indexed
view can be used for a given query execution. The view does not need to be referenced
directly in the query, for the optimizer to use it in the query execution plan. Therefore,
existing applications may take advantage of the indexed views without any changes
to the applications themselves; only the indexed views have to be created.
In fact, the optimizer always tries to find the best way to execute the query and it sometimes
decides to use the index defined on the base table, rather than using the index created on
view. In a development environment, we can test the execution of a query directly or in the
indexed view. If the optimizer uses the base table's index for both executions, we can force it
to use the index defined on the view while executing the view with the WITH NOEXPAND hint.
 
Search WWH ::




Custom Search