The accepted answer misses an important detail, as an index also works backwards. So if you have ASC index, a DESC query uses that index without having to scan the table.
So to extend the answer:
You might wonder why bother providing all four options, when two options together with the possibility of backward scan would cover all the variants of
ORDER BY. In single-column indexes the options are indeed redundant, but in multicolumn indexes they can be useful. Consider a two-column index on(x, y): this can satisfyORDER BY x, yif we scan forward, orORDER BY x DESC, y DESCif we scan backward. But it might be that the application frequently needs to useORDER BY x ASC, y DESC. There is no way to get that ordering from a plain index, but it is possible if the index is defined as(x ASC, y DESC)or(x DESC, y ASC).






















