IN processes entire subquery. EXISTS stops at first match (faster).
Slow (IN):
SELECT * FROM Customers
WHERE CustomerId IN (
SELECT CustomerId FROM Orders WHERE Total > 1000
);
-- Processes ALL matching orders
Fast (EXISTS):
SELECT * FROM Customers c
WHERE EXISTS (
SELECT 1 FROM Orders o
WHERE o.CustomerId = c.CustomerId AND o.Total > 1000
);
-- Stops at FIRST match per customer
Performance: EXISTS can be 5-100x faster on large datasets!
Rule: Use EXISTS for existence checks, IN only for small fixed lists.
