Checking if records exist with COUNT(*) > 0 is slow. EXISTS stops at first match.
Slow Way:
IF (SELECT COUNT(*) FROM Orders WHERE CustomerId = 123) > 0
BEGIN
PRINT 'Customer has orders'
END
-- Counts ALL orders even though we only need to know if ANY exist
Fast Way:
IF EXISTS (SELECT 1 FROM Orders WHERE CustomerId = 123)
BEGIN
PRINT 'Customer has orders'
END
-- Stops immediately after finding first order
Performance: Customer with 10,000 orders – COUNT takes 50ms, EXISTS takes 0.1ms.
