What do you guys think about: After each query, I put "Order BY PrimaryKey DESC" VS I set "PrimaryKey Sort by DESC Default" and each query I don't need to put Order By there.

Which one will be faster and skip the sort? OR both of them do sort? nothing optimize ?

  • to guarantee the resulset to be sorted you need to use ORDER BY even if you want to sort it ascending Feb 9, 2020 at 17:34

1 Answer 1


Before MySQL 8.0, and MariaDB:

You may use DESC in an index declaration, but it is ignored. (The PRIMARY KEY is an index.)

You must say DESC in the ORDER BY clause if you want the resultset sorted that way.

For multi-column indexes, all columns in ORDER BY should go the same way (all ASC or all DESC) in order to be able to use an INDEX. (There are many cases where an index won't be useful for ORDER BY anyway.)

MySQL 8.0: DESC is honored in INDEXes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.