Right now we do most time-related queries with this structure:
SELECT count(down_id) FROM track_e_downloads WHERE DATE_ADD(down_date, INTERVAL 5 MINUTE) >= '2021-09-21 20:50:02';
This seems to be very difficult for MySQL to optimize (not able to use an index on track_e_downoads.down_date, for example).
It looks like a first pre-query to get DATE_ADD() in a string and then just comparing the date string to down_date straight would be enough.
Right now we do most time-related queries with this structure:
SELECT count(down_id) FROM track_e_downloads WHERE DATE_ADD(down_date, INTERVAL 5 MINUTE) >= '2021-09-21 20:50:02';This seems to be very difficult for MySQL to optimize (not able to use an index on
track_e_downoads.down_date, for example).It looks like a first pre-query to get DATE_ADD() in a string and then just comparing the date string to
down_datestraight would be enough.