I made a view that does some query logic for a table of products. When I select from that view like
Select * from dbo.productView where productID = UUID
the execution plan is horribly inefficient. But if I take the query that generates the view and just add the where clause to it, the execution plan is exceedingly efficient. Why would these produce such radially different execution plans. I thought in the case of normal views (not indexed) the query analyzer would expand the view, so in effect it would be like adding the where clause to the SELECT that makes up the view.
I can't just index the productView since it uses a CTE and windowing functions, but I'd like to be able to the query analyzer to generate a more performant execution plan, like from the plain select.