I've been trying to use an index in my query but to no avail. It's defined, but not used.
Here are my indexes
Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment
--------------------------------------------------------------------------------------------------------------------------------------------------------
alerts | 1 | date_index | 1 | date | A | 9825 | NULL | NULL | | BTREE
This my query + explain:
EXPLAIN SELECT latitude, longitude, msg_id
FROM alerts
FORCE INDEX(date_index)
WHERE date>1336312075;
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
--------------------------------------------------------------------------------------------------------
| 1 | SIMPLE | alerts | ALL | date_index | NULL | NULL | NULL | 9825 | Using where |
The table has 9825 rows, and the date I chose was among the latest 9.... so it should have scanned only 9 rows.
Any ideas? Thanks