Re: retrieve rows in a specified order

From: Christopher Browne <cbbrowne_at_acm.org>
Date: 3 Jan 2004 22:06:42 GMT
Message-ID: <bt7edi$43s91$5_at_ID-125932.news.uni-berlin.de>


Martha Stewart called it a Good Thing when Adrian Kubala <adrian_at_sixfingeredman.net> wrote:
> RDBMSes have explicit ordering, in that if you want a particular
> order, you must explicitly specify it. Implicit ordering would be if
> each row implicitly had an ordering field tacked on which was
> implicitly used in queries where no ordering was given. And it would
> probably require some new operations to modify this implicit
> ordering.

Well, there always is _some_ sort of implicit order; it's just that it may be remarkably arbitrary.

For instance, it would be quite reasonable for   SELECT * FROM MY_TABLE
to return elements in the following order:

  1. Firstly, return elements on the pages that are cached in memory, in the order that they occur on those cache pages;
  2. Then, for pages _not_ cached, in the dual order:
    1. For each page that has to be retrieved,
    2. In the order that tuples are stored on those pages.

If data was inserted in some "sorted" order, it would be not too surprising for that order to be very nearly replicated. As records were deleted/added, that order would gradually evaporate...

-- 
select 'cbbrowne' || '_at_' || 'ntlug.org';
http://www3.sympatico.ca/cbbrowne/linux.html
Editing is a rewording activity.
-- Alan Perlis
[And EMACS a rewording editor.  Ed.]
Received on Sat Jan 03 2004 - 23:06:42 CET

Original text of this message