Reputation: 523
Which way is better:
DATE(updated_at) = DATE('2015-03-01 14:34:12')
or
DATEDIFF(updated_at, '2015-03-01 14:34:12') = 0
Upvotes: 0
Views: 102
Reputation: 1270773
For performance, you want:
(updated_at >= DATE('2015-03-01 14:34:12') and
updated_at < date_add(DATE('2015-03-01 14:34:12'), interval 1 day)
)
This allows MySQL to use an index on updated_at
for the query. When you put a column in a function, an index normally cannot be used.
Upvotes: 1