0

Can I somehow force an execution plan to a view?

I came across to parameter sniffing and I cannot add option recompile to a query because it is generated by DevExpres, so the only option is to change the view

1

1 Answer 1

3

You can't force an execution plan on a view. Depending on how the view is accessed, SQL Server will generate a different plan.

Querying a view without a where clause may result in table scans, but querying the same view with a predicate on AccountID could result in seeks.

It sounds like you might want to research plan guides, which will allow you to supply query hints (including the USE PLAN hint) without modifying the incoming query. If you're using SQL Server 2016 or newer, you can also use Query Store to force a plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.