Re: CLUSTERD INDEXES
From: Delbert Glass (delbert_at_noincoming.com)
Date: 02/27/04
- Next message: Joe Celko: "Re: Date queries"
- Previous message: Graham Blandford: "'Identical' SPROCS one with an error the other OK???"
- In reply to: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Next in thread: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Reply: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Feb 2004 12:02:16 -0600
>Specifying an ORDER BY clause on the clustered index will not cause the
>optimizer to include a Sort operator in the execution plan
True:
[ ] always
[x] sometimes
[ ] never
That "sometimes" even applies whenever you add the qualification that the
ORDER BY clause and the clustered index both specify the same order.
Bye,
Delbert Glass
"Jacco Schalkwijk" <NOSPAMjaccos@eurostop.co.uk> wrote in message
news:uoB6fZV$DHA.3500@tk2msftngp13.phx.gbl...
> Hi Abraham,
>
> Specifying an ORDER BY clause on the clustered index will not cause the
> optimizer to include a Sort operator in the execution plan, but it will
> change the way the rows are retrieved. If you run the following in Query
> Analyzer:
> USE Northwind
> GO
> SELECT orderid FROM orders
> GO
> SELECT orderid FROM orders
> ORDER BY orderid
>
> You will see that a different index is used to retrieve the rows, and that
> when you look closely at the index scan for the second statement, it
> includes the ORDERED FORWARD clause.
>
> As has already been said in other replies, if you don't specify with an
> ORDER BY clause that you want to have results returned in a certain order,
> the Query Optimizer will return the results in the quickest way possible
> (that's why it is called an Optimizer :-)), and that is far from
guaranteed
> to be in any order at all.
>
> --
> Jacco Schalkwijk
> SQL Server MVP
>
>
> "Abraham" <binu_ca@yahoo.com> wrote in message
> news:eTGes8U$DHA.1956@TK2MSFTNGP10.phx.gbl...
> > Hi,
> > I have a question about CLUSTERED INDEX. When we use ORDER BY in a
> clustered
> > index column , we found out that optimizer skips the sorting since it
get
> > the records in sorted manner.
> >
> > My question is that on multi-processor server does the SELECT return the
> > rows in the CLUSTERED INDEX order, if I do not include 'ORDER BY'
clause?
> > Thanks,
> > Binu
> >
> >
>
>
- Next message: Joe Celko: "Re: Date queries"
- Previous message: Graham Blandford: "'Identical' SPROCS one with an error the other OK???"
- In reply to: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Next in thread: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Reply: Jacco Schalkwijk: "Re: CLUSTERD INDEXES"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|