If items are inserted in a table, and then I write a query, such as select * from table
, why are the results not in the order that I expect?
It is a common misconception to expect results in the order that is inserted. Even when a clustered index is used, the result set may not be as expected. Only way to force an order is to use an "order by" clause. The reason that the order is different from what is expected may vary. The query may be executed in parallel and the result set may be merged or it may be due to the query optimization plan while trying to return the result set as fast as possible.