StmtText ---------------------------------- select * from contact where 1=0 StmtText ------------------- |--Constant ScanAnd to give you an idea, if we make a simple change so that we're using a variable instead of a constant, this is the showplan that gets generated:
StmtText ---------------------------------------- declare @x int set @x = 1 select * from contact where @x = 0 StmtText ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |--Filter(WHERE:(STARTUP EXPR([@x]=0))) |--Compute Scalar(DEFINE:([contact].[reversePhone_pager]=reverse([contact].[phone_pager]), [contact].[reversePhone_fax]=reverse([contact].[phone_fax]), [contact].[reversePhone_mobile]=reverse([contact].[phone_mobile]), [contact].[reversePhone_work]=reverse([contact].[phone_work]), [contact].[reversePhone_home]=reverse([contact].[phone_home]))) |--Clustered Index Scan(OBJECT:([gs13].[dbo].[contact].[cidx_contact_groupid_contactid]))Which is really interesting because it shows that SQL Server can optimize the predicate to either a TRUE nor FALSE until execution. So it has decided to scan the clustered index (basically doing a table scan) and evaluating the expression as part of the filter.
>>... WHERE 1=2 >>>