Here is my table:
// mytable
+----+---------+-------------+
| id | user_id | unix_time |
+----+---------+-------------+
| 1 | 324435 | 1481199265 |
| 2 | 745645 | 1481194241 |
| 3 | 547346 | 1481291987 |
+----+---------+-------------+
And this is my current composite index:
mytable(user_id, unix_time)
And this is one of my queries:
DELETE FROM mytable WHERE unix_time < unix_timestamp(subdate(now(), interval '1' YEAR))
I've read somewhere:
When there is
>
or<
orBETWEEN
or>=
or<=
operators, then that column should be the last one in the composite index.
So as you see, there is both <
operator and unix_time
is the last one in my current index (I've created index above because of another query) .. Now I want to know, Either:
- Do I need to create one more index like
mytable(unix_time)
to benefit query about
Or
- Quoted sentence is right and no need to any index else for query above
?