Re: Compound Primary Key - order not as expected
- From: "Damien" <Damien_The_Unbeliever@xxxxxxxxxxx>
- Date: 28 Apr 2006 05:59:33 -0700
John Rivers wrote:
Hello,Um. No. I've seen it return them out of order with only a few hundred
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)
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
.
- References:
- Compound Primary Key - order not as expected
- From: John Rivers
- Re: Compound Primary Key - order not as expected
- From: --CELKO--
- Re: Compound Primary Key - order not as expected
- From: John Rivers
- Compound Primary Key - order not as expected
- Prev by Date: Re: Compound Primary Key - order not as expected
- Next by Date: Re: Compound Primary Key - order not as expected
- Previous by thread: Re: Compound Primary Key - order not as expected
- Next by thread: Re: Compound Primary Key - order not as expected
- Index(es):
Relevant Pages
|