MYSQL ORDER BY
The clauses in a SELECT have a specific order:
ORDER BY x
x can be any datatype.
.NULLs precede non-NULLs.
.The default is ASC (lowest to highest)
.Strings (VARCHAR, etc) are ordered according the COLLATION of the declaration
.ENUMs are ordered by the declaration order of its strings.
ASCending / DESCending
.ASC = ASCENDING, DESC = DESCENDING
.NULLs come first even for DESC.
.In the above examples, INDEX(x), INDEX(lastname, firstname), INDEX(submit_date) may significantly improve performance.
But... Mixing ASC and DESC, as in the last example, cannot use a composite index to benefit. Nor will INDEX(submit_date DESC, id ASC) help -- "DESC" is recognized syntactically in the INDEX declaration, but ignored.