I have a query with an ORDER BY
clause that is slow due to the table having over 11 million rows.
I can speed it up dramatically by adding a clustered index on the column in the ORDER BY
clause. However, the software creates the query to order by different columns, depending on user settings. And you cannot add more than one clustered index to a table.
My question is: can non-clustered indexes be used to improve ORDER BY
performance? Or is there something special about clustered indexes that means I will not be able to sort quickly for all columns?
Note: I've posted my real query and execution plan online but there are other issues that I don't want to go into here. I didn't create the database or write the query. And the query is still very slow even without the IN
clause.