SQL Interview: 98 Reading tables in non-clustered index order
This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Development Level: Medium
Question:
If you are SELECTing from a table and the ORDER BY clause in your query is in the same order as a non-clustered index, will the non-clustered index be used?
Answer:
It might or it might not.
While the non-clustered index could be helpful, it depends which columns are being read from the table. In many cases, reading directly from the heap or clustered index and then sorting the data later might lead to a better query plan.
2025-12-19