SELECT problems . * , users.id AS new_user_id, users.nick AS nick
FROM problems, users
WHERE problems.deleted =0
AND problems.topic_id =1
AND problems.user_id = users.id
AND problems.id NOT
IN (
SELECT DISTINCT (problem_id)
FROM problems_attempted
WHERE user_id =1
AND total_questions = ( attempted_right + attempted_wrong + skipped )
)
ORDER BY problems.updated DESC
Can this query be optimized for a better performance?