How Does MySQL Process order by and limit in a Query?
The MySQL query optimizer processes a WHERE clause in Statement Optimization Mode. The optimizer first searches through the results of previous query executions for a match for the current WHERE clause. If it finds one, it will look at it. The query execution then continues with ORDER BY clauses and LIMIT clauses.
limit offset order by mysql
SELECT column_list FROM table1 ORDER BY column_list LIMIT row_count OFFSET offset;
If it doesn’t find anything, it then queries the tables specified by ORDER BY but only if there are not more than 30 rows per table.