ORDER BY x ASC -- same as default ORDER BY x DESC -- highest to lowest ORDER BY lastname, firstname -- typical name sorting; using two columns ORDER BY submit_date DESC -- latest first ORDER BY submit_date DESC, id ASC -- latest first, but fully specifying order.
NULLscome first even for
INDEX(submit_date)may significantly improve performance.
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.