Clustered indexes

  • I have a clustered index defined as follows:

    CREATE UNIQUE CLUSTERED INDEX [ui_WordID] ON [dbo].[tblKeyJoin]([WordID], [TotalFactor] DESC , [ImageID]) WITH FILLFACTOR = 90 ON [PRIMARY]

    When I perform a query such as 'Select TOP 100 WordID, TotalFactor from tblKeyjoin where WordID=64' the results seems to come back ordered like the clustered index for TotalFactor even though I don't use an ORDER BY clause. Is that true or is it a coincidence?

  • That's normal but not guaranteed.

    It's best to explicitly order any result set that should be ordered. It doesn't cost you anything but the extra typing.

    --Jonathan



    --Jonathan

  • Yes, it is best to explicitly set up the Order By instead of relying on luck.

    Dr. Peter Venkman: Generally you don't see that kind of behavior in a major appliance.

    Patrick

    Quand on parle du loup, on en voit la queue

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply