Thanks, but it doesn’t solve the problem.
I need the results orderd by id, but when I add “ORDER BY id” in the query, mysql uses filesort which is very slow.
Any other idea?
ALTER TABLE name_index ADD INDEX name_index_ix_name_id (name, id);
That will create a combined index for you.
Which combined with your:
SELECT name, id FROM name_index WHERE name LIKE ‘sai%’ ORDER BY id LIMIT 10
should be fast enough for your needs.
The trick is that the combined index has all the where columns in the index and the order by column is last.
That gives mysql the chance to use the index to solve both the where part and the order by.