Looking through a few SQL implementations, I noticed that most DBMSs support defining an index on a column with a descinding order, e.g.
CREATE INDEX anIndex ON aTable (aColumn DESC);
When would this be advantageous over an ASC index? Why is ASC or DESC part of the index definition?
If the implementation of an index is efficient (B-tree or even a binary search in a sorted list), I can’t see any material difference between an ASC or DESC index.
What am I missing?
If the table is clustered, the index in fact becomes this:
and can be used in queries like
or
, but not in
For composite indexes, the columns can be ordered in opposite directions as well: