I'm trying to figure out which is faster, a clause like "WHERE IN (SELECT 1 FROM MyTable)", or a clause like "WHERE EXISTS (SELECT 1 FROM MyTable).
Let's use the query from the SqlServer documentation:
SELECT * FROM Orders
WHERE ShipRegion = 'WA' AND EXISTS (
SELECT EmployeeID FROM Employees AS Emp
WHERE Emp.EmployeeID = Orders.EmployeeID)
Or
SELECT * FROM Order
WHERE ShipRegion = 'WA' AND EmployeeID IN (
SELECT EmployeeID FROM Employees AS Emp
WHERE Emp.EmployeeID = Orders.EmployeeID)
I'd like to know the answer, if anyone has it, but I'd really like to know how to test it for myself in SqlServer 2005. (I'm a noob at SqlServer.)
Thanks!