This compilation does not create any statistics on the indexed view.
We are now asked to write a query that shows the total quantity of orders per customer, for a particular range of products.
We now execute our basic query against the view on an Enterprise Edition instance, without any hints: hint, so statistics on the Customer ID column of the indexed view were not automatically created.
The statistics on Customer ID are not actually terribly important in this simplified example, but that will not always be the case.
The query below expresses the same logical requirement, but does not reference the view: This query produces the following execution plan: This plan features one less aggregation operation than before.
When view expansion was used, the query optimizer was unfortunately unable to remove a redundant aggregation operation, resulting in a less efficient execution plan.