Take the 2-minute tour ×

When I look at the execution plan for a SELECT query, I often notice sorts thrown in there hogging CPU. The problem is that I don't have any order by's in my query, and it looks like the cause of the sorts are ascending/descending order set for the column on the index used in the query.

Why is this happening, and can it be turned off (and should I) ?

share|improve this question
can you provide an example? –  Markus Winand Mar 16 '11 at 17:36

2 Answers 2

There are quite a few operations in SQL Server that can cause a sort being added to the plan without an ORDER BY being in the query.

DISTINCT and UNION will cause a sort to get rid of duplicates.

GROUP BY might require a sort on the GROUP BY column if the plan has a stream aggregate rather than a hash aggregate and there is no suitable index that returns the required data pre-sorted.

The segment iterator (used for ranking functions) requires its input sorted on the segment column.

Do you have a particular example?

share|improve this answer

The result is sorted using the index automaticaly. You can specify the an order by clause.
It's the purpose of an index, sort data in order to find some lines quickly.

share|improve this answer

Your Answer


