Posted by Damien on 04/28/06 15:59
John Rivers wrote:
> Hello,
>
> when a clustered index is present the records *are* physically ordered
> on disk to match the index
>
> that is the whole point of a clustered index
>
> and by default a select statement with no ORDER BY will always return
> data in the order of the clustered index (when present)
>
Um. No. I've seen it return them out of order with only a few hundred
rows. As soon as the table is occupying more than one page, the query
optimizer *can* decide to produce a parallel plan. You'll see the
result as chunks of output which are in clustered index order, but no
deterministic ordering between the chunks. e.g. it'll look like:
1
2
3
4
5
11
12
13
14
15
6
7
8
9
10
The *only* way to guarantee the order of output is to put an order by
clause on your select statement.
Damien
Navigation:
[Reply to this message]
|