For simplification, I have two tables related with one to many using a foreign key, for example:
Users table:
id
name
Actions table:
id
user_id
<
SELECT u.id
FROM users u
LEFT JOIN actions a
ON a.user_id = u.id
WHERE a.user_id IS NULL
Optimized version would be:
SELECT u.id
FROM users u
LEFT JOIN actions a
ON a.user_id = u.id
AND ISNULL(a.user_id)
select u.id
from users u
left outer join actions a on a.user_id = u.id
where a.user_id is null