Kevin Eckart investigates filtered indexes not being used:
This warning is telling me that Parameterization is to blame for the filtered index not being used. From here, I see 3 options.
-
Remove the parameters and use literals. (not practical)
-
Use Dynamic SQL
-
Use OPTION(RECOMPILE) at the bottom of the query.
This is the classic issue with filtered indexes: you expect them to be used, but when you check the plan, they aren’t.