Skip to main content
3 of 3
Add mysql tag
RolandoMySQLDBA
  • 184.4k
  • 33
  • 323
  • 531

Need to optimize simple SELECT query for InnoDB table with 2million rows

I'd like to make this query the fastest possible, since it's called really often.

SELECT login_events.id 
FROM login_events 
WHERE (
  DATE(created_at) >= DATE(CURRENT_DATE) 
  AND person_id = 1
) 
LIMIT 1

It's running on a 157.7mb InnoDB table (says navicat), with ~2million rows and indexed on [created_at, person_id].

Using EXPLAIN I see it's using the index, but it says "Using where; Using index;". What can I do to make this the fastest possible? Would switching to MyISAM gain me anything?