i want to get all active users in the past 24 hours, and see whether they've interacted with us before. i have the following query:
SELECT $
DISTINCT user_id $
FROM $
activity $
WHERE user_id in (SELECT $
DISTINCT user_id $
FROM $
activity $
WHERE $
date > DATE_SUB(NOW(), INTERVAL 24 HOUR)) AND $
date < DATE_SUB(NOW(), INTERVAL 24 HOUR);
i have indexes on user_id and date. can this be made more efficient?