Re: Do I care about this?
From: Kalen Delaney (replies_at_public_newsgroups.com)
Date: 09/15/04
- Next message: Chris: "Is this possible"
- Previous message: TomT: "RE: Trying to avoid using a cursor...."
- In reply to: Mike Labosh: "Re: Do I care about this?"
- Next in thread: Mike Labosh: "Re: Do I care about this?"
- Reply: Mike Labosh: "Re: Do I care about this?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 15:16:22 -0700
My guess is that because the nc index is covering is the reason it is being
used.
But I want to comment on this statement:
>> It seems logical to me that the fastest way to fetch them all would be in
> the order that the pages are arranged on the disk, which in this case is
> the order of the clustered primary key
The clustered index does not indicate the ON DISK order.
Pages for a table can be anywhere; they are only logically ordered by the
clustered key. Each page has a pointer to the next one in sequence, but page
77 could follow page 120 and page 500 could follow 77.
But you are right that SQL Server will usually want to fetch the pages in
disk order, but since that is frequently not clustered index order, you will
get a seemingly random ordering of your rows.
Even on the pages themselves, the rows are not stored in physical order.
They are stored wherever there is room on the page, and there is an offset
table at the bottom of the page to keep track which is the first row in
logical order, which is the second and which is the third.
-
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Mike Labosh" <mlabosh@hotmail.com> wrote in message
news:%23IxAKV1mEHA.3684@TK2MSFTNGP10.phx.gbl...
>> Check the execution plan, sql server is not using the clustered index.
>
> Freaky. If the query is this:
>
> SELECT * FROM LastNameSuffix
>
> It seems logical to me that the fastest way to fetch them all would be in
> the order that the pages are arranged on the disk, which in this case is
> the order of the clustered primary key. If the data engine used the
> unique constraint index on the other column, isn't that more work because
> it has to hop over all those nonclustered index pages, and then hop around
> on the disk on the data pages? Although, 8 tiny records like this
> probably fit nicely on a single data page.
>
> --
> Peace & happy computing,
>
> Mike Labosh, MCSD
>
> Feed the children!
> Save the whales!
> Free the mallocs!
> "Alejandro Mesa" <AlejandroMesa@discussions.microsoft.com> wrote in
> message news:08E3434D-77AD-446A-89B0-C0BB9F968081@microsoft.com...
>>
>>
>> AMB
>>
>> "Mike Labosh" wrote:
>>
>>> Thanks, all, I guess I am just obsessing too much.
>>>
>>> --
>>> Peace & happy computing,
>>>
>>> Mike Labosh, MCSD
>>>
>>> Feed the children!
>>> Save the whales!
>>> Free the mallocs!
>>>
>>>
>>>
>
>
- Next message: Chris: "Is this possible"
- Previous message: TomT: "RE: Trying to avoid using a cursor...."
- In reply to: Mike Labosh: "Re: Do I care about this?"
- Next in thread: Mike Labosh: "Re: Do I care about this?"
- Reply: Mike Labosh: "Re: Do I care about this?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|