QuestionQ4

Secure, optimize, and deploy database solutions

You have an Azure SQL database that contains order data.

A reporting query that aggregates monthly revenue for each customer runs frequently. You need to reduce the time required to retrieve the computed values. The solution must not change any underlying table structure.

What should you do?

Explanation

An indexed view materializes the aggregation in a unique clustered index, which can reduce repeated computation of monthly revenue per customer. For an indexed view, the view must use WITH SCHEMABINDING; when its definition uses GROUP BY, it must also include COUNT_BIG(*). The unique clustered index is the initial index required to materialize the view.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!