You are here: Re: Compound Primary Key - order not as expected « MsSQL Server « IT news, forums, messages
Re: Compound Primary Key - order not as expected

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация