any ideas of how to optimize the following query:
SELECT ip FROM clicks
WHERE ip = ?
AND SECOND(date_clicked)+4 > SECOND(NOW())
AND MINUTE(date_clicked) = MINUTE(NOW())
AND HOUR(date_clicked) = HOUR(NOW())
AND DATE(date_clicked) = DATE(NOW())
I mean, would be great to reduce number of DATE/TIME checks if possible. The main goal of that query is to see if click from specific IP did occur within 4 secs.
cheers, /Marcin
MINUTE( '16:05:59' ) != MINUTE( '16:06:01' ).