📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

What is an indexed view in SQL Server, and when is it worth the write cost?

Junior Theory Beginner

🎯 Key points

  • Requires WITH SCHEMABINDING and a unique clustered index
  • Rows are stored and maintained synchronously on base table writes
  • Good for read-heavy aggregates (COUNT_BIG, SUM)
  • Adds write cost and contention on hot aggregate rows
  • Automatic matching in Enterprise/Azure SQL; NOEXPAND hint elsewhere
  • Many restrictions: no outer joins, no non-deterministic functions

⏱ 30-second answer

An indexed view is a view created WITH SCHEMABINDING that has a unique clustered index, so SQL Server stores its rows and maintains them on every change to the base tables. It suits read-heavy aggregates (daily sales totals) where the base data changes slowly. Every insert, update or delete on a base table also updates the view, which adds write cost and can cause blocking on hot aggregate rows. Enterprise edition and Azure SQL can match it automatically; Standard needs WITH (NOEXPAND).

🔍 What the interviewer is checking

Checks understanding of materialisation, SCHEMABINDING, NOEXPAND and write overhead.

↩ Usually asked after

More in SQL Features

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me