January 2019
Intermediate to advanced
286 pages
7h 41m
English
In this section, we will learn how to optimize an ORDER BY which in general causes in many cases mentions in the EXPLAIN plan like filesort.
More often than not, the filesort operation in the example can be rather time-consuming (even if it does not require the creation of a file on disk). This is especially true if MySQL has a large number of records to sort.
Let's take our WHERE example and add an ORDER BY:

To optimize this query, we can use a combined index:
Alter combine(job_id, datehired);
We combine the job_id and datehired column because we use them in a WHERE and an ORDER BY, and we create ...
Read now
Unlock full access