May 2019
Intermediate to advanced
484 pages
11h 23m
English
Inequality logic is logic that involves negative comparisons, such as !=, <>, NOT IN, or NOT LIKE. This type of predicate can be costly because it often results in evaluating each row, which translates to scan operations. Consider the following queries from the AdventureWorks database:
SELECT BusinessEntityID, FirstName, LastNameFROM Person.PersonWHERE PersonType NOT IN ('EM','SP','IN','VC','GC');SELECT BusinessEntityID, FirstName, LastNameFROM Person.PersonWHERE PersonType = 'SC';
These queries are logically equivalent, since SC is the only PersonType that is not listed in the first query. Out of the box, the execution plans look like this:
At this point, they appear to have the same estimated cost, but notice that both ...
Read now
Unlock full access