Re: Compound Primary Key - order not as expected



John Rivers (first10@xxxxxxxxxxxxxx) writes:
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

Actually, they are ordered if you follow the page links. But if pages
are in disorder, the physical order on disk may be yet another one.

and by default a select statement with no ORDER BY will always return
data in the order of the clustered index (when present)

No. This may have been true by chance for SQL Server up version 6.5. It is
definitely not correct for SQL 7 and later.




--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Unique
    ... one index, the primary key, this should also be a clustered index (unless ... And this is far from always an apparent choice. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.programming)
  • Re: Do I care about this?
    ... > the order of the clustered primary key ... The clustered index does not indicate the ON DISK order. ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Transform/transfer 50Gb - how to do it fast?
    ... I'm also plan to make newtable partioned. ... If new the table will have the same clustered index as the old table, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Need ammunition against clustered index hampers performance
    ... I can't find ANY resource on the internet that ... Following their own guidelines, there is no clustered index in sight, ... SQL Server MVP Greg Linwood has argued fiercely for heaps, ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: deadlock problem
    ... how do i do this?do u mean that i should reconsider the columns that i ... use in clustered index? ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)