“Clustered index” and “Order by Clause”

前端 未结 5 1457
慢半拍i
慢半拍i 2021-02-06 00:28

Is there any difference between Clustered Index and Order by Clause?

I have to populate the Dropdown from the Master Table and followin

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 01:18

    Apples and Oranges. A clustered index is a storage option. An ORDER BY is a query option. If you need ordered results, the only way to get them is to add an ORDER BY clause to your query. Period.

    An index may help the query optimizer generate a more efficient plan and leverage the index as a means to satisfy the ORDER BY requirement. But by no means will the presence of an index, clustered or non-clustered, guarantee any ordering of a result.

    So you absolutely need ORDER BY in your queries. You also may consider an index by Name column to help this the query. Whether an index will be used or not, it depends on many more factors. you should read Designing Indexes and The Tipping Point.

提交回复
热议问题