I have the following query:
SELECT MIN(myColumn) as myColumn
FROM myTable
WHERE date(time_stamp) = curdate() AND id = 1;
This currently works but is really slow when there is a lot of data present in the database.
I tried it using this:
SELECT MIN(myColumn) as myColumn
FROM myTable
WHERE time_stamp >= (now() - interval 1 day) AND id = 1;
This query is pretty fast but the problem is i’m getting data for the past 24 hours instead of just the current day as of 12AM. I’m assuming the date() conversion is slowing it down a lot. Is there a better way to do the first query to speed it up?
The simple way can be
or similar.