CREATE TABLE `a` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`parent` int(11) DEFAULT NULL,
`position` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `parent` (`parent`,`position`)
) ENGINE=InnoDB
mysql> explain select id, name from a order by parent,position;
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | a | ALL | NULL | NULL | NULL | NULL | 3 | Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)
mysql> explain select id, name from a force index(parent) order by parent,position;
+----+-------------+-------+-------+---------------+--------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+--------+---------+------+------+-------+
| 1 | SIMPLE | a | index | NULL | parent | 10 | NULL | 3 | |
+----+-------------+-------+-------+---------------+--------+---------+------+------+-------+