Optimize ORDER BY on a key column particularly when used with LIMIT on a huge table
Use case: Using ORDER BY/DESC
with LIMIT
in combination with a CREATE VIEW
allows us to see a limited set of data when there is a lot of data to see.
Currently, doing this with key field does not use the key, and Octo gets stuck generating the local index for ORDER_BY, which in this case is not needed.
Here is a sample query on the names table that shows the behavior:
select * from names order by id desc limit 1;