I\'m curious which of the following below would be more efficient?
I\'ve always been a bit cautious about using IN
because I believe SQL Server turns th
To optimize the EXISTS
, be very literal; something just has to be there, but you don't actually need any data returned from the correlated sub-query. You're just evaluating a Boolean condition.
So:
WHERE EXISTS (SELECT TOP 1 1 FROM Base WHERE bx.BoxID = Base.BoxID AND [Rank] = 2)
Because the correlated sub-query is RBAR
, the first result hit makes the condition true, and it is processed no further.