Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

View Running Slow w/ Unqualified Order By

0 views
Skip to first unread message

aeden....@gmail.com

unread,
Dec 21, 2009, 11:53:32 PM12/21/09
to
Suppose I have a view named "Stuff". When selecting from the the view
like this,

select * from stuff order by Id

the query runs very slow. However when I qualify the Id column with
one of the aliases in
the underlying query of the view like this

select * from stuff order by s.Id

the query runs 10-12 times faster. Why is that?

Cheers,
Aeden

Uri Dimant

unread,
Dec 22, 2009, 12:15:55 AM12/22/09
to
Hi
I think that it because of SQL Server does not need to get to the datapages
('touching' the table) to return the data (RID) but traverse trou the index
pages to to get the data (the column ID to satisfy the query IS already
stored in the index)

Have you compare bot execution plans?

<aeden....@gmail.com> wrote in message
news:b6e1bc20-a544-4b63...@h14g2000pri.googlegroups.com...

0 new messages