There are two PRIMARY directions to sort data in SQL: Ascending
(ASC) and Descending DESC.
When these two sort definitions are put together in a single
statement a filesort is produced.
Why do we want to avoid filesorts?
Filesorts are bad. 1st they tickle a thread based buffer called
sort_buffer_size. Additionally filesorts reads the data twice,
unless max_length_for_sort_data limit is reached and as a result
the Filesort runs slower to reduce disk I/O. If you want
filesorts to run faster at the expense of the disk increase the
default max_length_for_sort_data. You can read the filesort
algorithm here.
So, here is an example
[Read more]
CREATE TABLE `ABCD` (
`A` int(10) unsigned NOT NULL default '0',
`B` int(10) unsigned NOT NULL default '0',
`C` int(10) unsigned NOT NULL …