Functions in our predicate
Search predicates should only use deterministic function calls. Calls to non-deterministic functions with columns for parameters cause the SQL Database Engine to be unable to reference the selectivity of those columns, as the result of the function is unknown at compile time. Because of this, they cause unnecessary scans.
Keep in mind what was discussed in previous chapters: that the Query Optimizer uses statistics and some internal transformation rules and heuristics at compile time to determine a good enough plan to execute a query; and how the WHERE
clause is one of the first to be evaluated during logical query processing. The Query Optimizer depends on the estimated cost to resolve the search predicates to choose whether to do seeks or scans over indexes.
The following example shows a query executed in the AdventureWorks
sample database that uses non-deterministic function calls in the search predicate:
SELECT SalesOrderID, OrderDate FROM Sales...