Enhancing performance by creating an indexed view
A view is a virtual table that consists of data columns from one or more tables. In simple terms, it is a stored query that works as an object of a database, such as a table. A view can be treated exactly like a table; it can be used in any stored procedure, Join
, UDF, and so on.
A view provides the following two main benefits:
A security mechanism that restricts users to a certain subset of data in one or more base tables
A mechanism that allows developers to customize how users can logically view the data stored in base tables
When you query the view, the query optimizer complies a single execution plan for the query. The query optimizer searches through a set of possible execution plans for a query, and chooses the lowest cost plan.
In the absence of an indexed view, the portions of the view necessary to solve the query are materialized at execution time. All joins and/or aggregations are done at execution time. After creating an indexed...