Sql Server predicates lazy?

后端 未结 4 1837
南旧
南旧 2021-01-17 21:01

I have a query:

SELECT 
    someFields 
FROM 
    someTable 
WHERE 
    cheapLookup=1 
    AND (CAST(someField as FLOAT)/otherField)<0.9

4条回答
  •  执笔经年
    2021-01-17 21:32

    What you're referring to is short-circuiting, like other languages (e.g. C#) support.

    I believe SQL Server can short-circuit but depends on the scenario / what happens in the optimizer so there is certainly not a guarantee that it will. It just might.

    Excellent reference on this by Remus Rusanu here:
    http://rusanu.com/2009/09/13/on-sql-server-boolean-operator-short-circuit/

提交回复
热议问题