SQL Server Interview Question #104
What is an indexed view?
Views, Stored Procedures & User-Defined Functions Mid-Level Intermediate
Quick Interview Answer
An indexed view is a view whose result is physically materialized through an index. The first index created on it must be a unique clustered index. Additional indexes can then be added.
Indexed views have strict requirements, including schema binding and restrictions on allowed query constructs. They can improve specific aggregation or read-heavy workloads, but they add storage and write-maintenance cost because underlying data changes must also maintain the indexed view.
They should be introduced only after measuring the workload and understanding SQL Server edition and optimizer behavior relevant to the environment.
Detailed Explanation
An indexed view is a view whose result is physically materialized through an index. The first index created on it must be a unique clustered index. Additional indexes can then be added.
Indexed views have strict requirements, including schema binding and restrictions on allowed query constructs. They can improve specific aggregation or read-heavy workloads, but they add storage and write-maintenance cost because underlying data changes must also maintain the indexed view.
They should be introduced only after measuring the workload and understanding SQL Server edition and optimizer behavior relevant to the environment.