I've got a table that refuses to use index, and it always uses filesort.
The table is:
CREATE TABLE `article` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Category_ID` int(11) DEFAULT NULL, `Subcategory` int(11) DEFAULT NULL, `CTimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `Publish` tinyint(4) DEFAULT NULL, `Administrator_ID` int(11) DEFAULT NULL, `Position` tinyint(4) DEFAULT '0', PRIMARY KEY (`ID`), KEY `Subcategory` (`Subcategory`,`Position`,`CTimestamp`,`Publish`), KEY `Category_ID` (`Category_ID`,`CTimestamp`,`Publish`), KEY `Position` (`Position`,`Category_ID`,`Publish`), KEY `CTimestamp` (`CTimestamp`), CONSTRAINT `article_ibfk_1` FOREIGN KEY (`Category_ID`) REFERENCES `category` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=94290 DEFAULT CHARSET=utf8
The query is:
SELECT * FROM article ORDER BY `CTimestamp`;
The explain is:
+----+-------------+---------+------+---------------+------+---------+------+-------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+---------+------+---------------+------+---------+------+-------+----------------+ | 1 | SIMPLE | article | ALL | NULL | NULL | NULL | NULL | 63568 | Using filesort | +----+-------------+---------+------+---------------+------+---------+------+-------+----------------+
When I remove the "ORDER BY" then all are working properly. All other indices (Subcategory, Position, etc) are working fine in other queries. Unfortunately, the timestamp refuses to be used, even with my simple select query. I'm sure I'm missing something important here.
How can I make MySQL use the timestamp index?
Thank you.