Re: Is bookmark in a nonclustered index ordered?
From: Paul S Randal [MS] (prandal_at_online.microsoft.com)
Date: 02/05/05
- Next message: MIcrosft_Public_SQLSERVER: "IPC : Named Pipes, RPC and Sockets etc."
- Previous message: David Portas: "Re: Is bookmark in a nonclustered index ordered?"
- In reply to: David Portas: "Re: Is bookmark in a nonclustered index ordered?"
- Next in thread: DC: "Re: Is bookmark in a nonclustered index ordered?"
- Reply: DC: "Re: Is bookmark in a nonclustered index ordered?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 5 Feb 2005 10:36:23 -0800
Here's an example of why you cannot rely on the order of rows returned
unless you specifically use an ORDER BY. We have a concept of merry-go-round
scans. If two queries need to perform a range scan over an index, they can
share the same scan. Now, if query one starts before query two, we still
recognize that the scan we need for query two is already under way and we
piggy-back on it until it completes. However, because we hopped on it after
it had started, we need to go back to the start of the scan to read the rows
we missed. (e.g. query one scans and returns rows 1 to 100. Query two starts
when query one's scan is at row 46. Query two thus returns rows 46 to 100
plus 1 to 45)
Regards.
-- Paul Randal Dev Lead, Microsoft SQL Server Storage Engine This posting is provided "AS IS" with no warranties, and confers no rights. "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:WvidncyWk-E2CZnfRVn-hg@giganews.com... > An index (clustered or non-clustered) shouldn't be relied upon to fix the > order in which rows are returned. There are no guarantees unless you use > ORDER BY in your query. Use ORDER BY and let the server decide which index > is most appropriate. > > -- > David Portas > SQL Server MVP > -- > >
- Next message: MIcrosft_Public_SQLSERVER: "IPC : Named Pipes, RPC and Sockets etc."
- Previous message: David Portas: "Re: Is bookmark in a nonclustered index ordered?"
- In reply to: David Portas: "Re: Is bookmark in a nonclustered index ordered?"
- Next in thread: DC: "Re: Is bookmark in a nonclustered index ordered?"
- Reply: DC: "Re: Is bookmark in a nonclustered index ordered?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|