Can I use an option hint in my view definition to make it run faster?
Can I use an option hint in my view definition to make it run faster?
Hints, sure... but not a query hint, as a view is just a stored SUB-query. It's a common misconception that a view is a stored query, and therefore should support things like an ORDER BY clause.
So, you can have table hints, such as NOLOCK, but not query hints such as RECOMPILE.
Before you try to fix the slowness, you must understand the cause. Options are the last resort because they force the query optimizer to execute the query in a certain way. It might work for now but, if the data population changes, you're preventing the query optimizer from evolving a new plan. The chances are that there's a simple reason the query is slow so you should examine the query plan first. Look for the bits that show the highest percentage of the cost and also look at the parts where the lines are thickest as they are processing the most rows.
No one has followed this question yet.