I'm trying to optimise my MySQL queries using EXPLAIN. Here is a very simply example of a query:
SELECT ID, Date, SenderID, Message FROM messages WHERE ReceiverID = '1000' ORDER BY ID DESC LIMIT 25;
When I view the EXPLAIN it shows:
+----+-------------+-----------+------+---------------+------------+---------+-------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+------+---------------+------------+---------+-------+------+-----------------------------+
| 1 | SIMPLE | messages | ref | ReceiverID | ReceiverID | 5 | const | 34 | Using where; Using filesort |
+----+-------------+-----------+------+---------------+------------+---------+-------+------+-----------------------------+
The number of results is 15. I have created an index for ReceiverID so I don't understand why 'rows' in the EXPLAIN is show 34? I also dont under why it's using filesort. This query isnt very slow but other queries with larger results tend to be slow and the 'row' figure seems to be almost double what I expect it to be...
Its probably something very straight forward but I must be missing something?