i've just wondered if there's a difference in cost(memory,cpu) of an EXISTS or NOT EXISTS in following queries. Does it make a difference if i select NULL, 1 or columns?
1)
SELECT id
FROM Parent p
WHERE NOT EXISTS
(
SELECT NULL FROM Child c
WHERE c.parent_Id = p.id
AND c.x <> c.y
)
2)
SELECT id
FROM Parent p
WHERE NOT EXISTS
(
SELECT 1 FROM Child c
WHERE c.parent_Id = p.id
AND c.x <> c.y
)
3)
SELECT id
FROM Parent p
WHERE NOT EXISTS
(
SELECT * FROM Child c
WHERE c.parent_Id = p.id
AND c.x <> c.y
)
Option 1 is what i use normally, is there are difference at all or is it optimised to the same?
