SQL Server:
First example:
1=1
predicate is automatically removed by SQL Server Query Optimizer because it's always true
:
Second example:
Because 1=2
predicate is always false
, the execution plan don't includes a data access operator (Table
/ Index
Scan
/ Seek
) to read data from dbo.Customer
table. Instead, the execution plan includes an Constant Scan
operator which will return the list of columns from dbo.Customer
table without any row. This is contradiction detection in action :-)
Note: I used SQL Server 2012 Developer Edition.