My query of interest is below
SELECT COUNT(a.id)
FROM users AS a
RIGHT JOIN date_log AS b
ON a.id = b.user_id
WHERE
b.meeting_date BETWEEN '2012-06-01'
AND DATE_ADD('2012-06-01', INTERVAL 1 MONTH)
GROUP BY a.id
However, it’s too slow when I try to select data from a large database.
I added ‘group by’ terms in the query for removing duplicated ids.
Is there better way to do this job?
If you just need the count, you can make this query a left-join, and see if MySQL has a better time executing it (I’m not sure how it actually performs RIGHT JOINs, but I can imagine it in ways which are inefficient compared to LEFTs…