1

If I have a simple table:

ArticleName (string)
CategoryID (int)
LastModified (datetime)

And I create an index:

CategoryID (ASC)
LastModified (ASC)

For the query:

SELECT * FROM table WHERE CategoryID = 1 ORDER BY LastModified ASC

Would I need a separate index for ordering by LastModified DESC?

Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
  • Not necessarily, but that would help to avoid SORT operator in execution plan. Usually they're costing quite a lot. – Evaldas Buinauskas Oct 08 '15 at 13:06
  • a good read - [link](http://stackoverflow.com/questions/743858/sql-server-indexes-ascending-or-descending-what-difference-does-it-make) – Abhishek Oct 08 '15 at 13:08

1 Answers1

3

No, not in SQL Server, and not in most DBMS that use B*tree indexes. This type of index can be traversed just as efficiently forwards as backwards, because the leaf nodes are joined into a double-linked list.

cliffordheath
  • 2,536
  • 15
  • 16