I have a query that has a where clause built using a number of local variables, This however is painfully slow. Below is a rough example as I don\'t have access to the query cur
No.
For constants, the optimizer can work out the best plan based on statistics for the given values.
When you use variable you are forcing parameterization and the plan will be designed to be reusable for a wide range of values.
In this case you can try OPTIMISE FOR UNKNOWN which may give better results. Or don't filter like this: use different queries for different permutations. Do you have LIKE too with leading wildcards?