Complex expressions
Search predicates should not use complex expressions. Much like the deterministic function calls we discussed in the Functions in our predicate section, complex expressions can also cause unnecessary scans.
As was discussed in previous chapters, the Query Optimizer uses statistics, internal transformation rules, and heuristics at compile-time to determine a good-enough plan to execute a query. This includes the ability to fold expressions, which is the process of simplifying constant expressions at compile-time. For example, a predicate such as WHERE Column = 320 * 200 * 32 is computed at compile time to its arithmetic result and internally the predicate is evaluated as WHERE Column = 2048000. Unlike constants, calculations ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access