Functions in our predicate

Search predicates should not use deterministic function calls. Calls to deterministic functions with columns for parameters cause SQL Server 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: 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; 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 in order to choose whether it seeks ...

Get Learn T-SQL Querying now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.