We’ve already discussed using the ORDER BY clause with subqueries. You can also, however, use the
clause with sorting results of one of the columns. Actually, this is most common way to use this clause.
Sometimes such queries require using temporary tables or filesort, and a regular
clause provides this information. But it doesn’t show if this job is needed for
or for optimizing another part of the query.
For example, if we take a pretty simple query (
select distinct last_name from employees order by last_name asc
) and run
on it, we can see …[Read more]