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
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)