The support page now asks for the visits of one user on one day. A report asks for all the visits of one day.
- Create an index named
visits_user_day_idxonvisits, onuser_idand thenvisited_on. - Show the plan of
SELECT * FROM visits WHERE user_id = 4242 AND visited_on = '2025-06-17'. Which kind of scan does it use? - Think before you run it: can
visits_user_day_idxserveSELECT * FROM visits WHERE visited_on = '2025-06-17'?user_idhas 10 000 different values. Answer yes or no. - Show the plan of that day query to check.
- Make the day query use an index. Then show its plan again.