Logically they are in the order indicated by @Lennart.
But your query is especially hard to optimize. There is no optimization for
WHERE constant BETWEEN col_start AND col_end The best the Optimizer can do is use an index on either or both columns, but then risk scanning half the table.
The Optimizer may use
INDEX(type_of_code) to help with the ordering and limiting of
ORDER BY type_of_code ASC LIMIT 1. With luck, it will find a row matching the
WHERE quickly; without luck, it might have to scan the entire table.
Have you supplied exactly the query in question? Let's see
SHOW CREATE TABLE. Also, to the ranges overlap? (The Optimizer cannot make a useful assumption here, but you can.) There may be some tricks to speed up the query, even if it has to scan the entire 5M rows.