Received: from secure.arcamax.com (secure.arcamax.com [209.96.210.67]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1NLOBx07167 for ; Fri, 23 Feb 2001 16:24:11 -0500 (EST) (envelope-from bryan@arcamax.com) Received: from bryan2 (bryan [209.96.210.45]) by secure.arcamax.com (8.9.3/8.9.3) with SMTP id QAA16754 for ; Fri, 23 Feb 2001 16:24:10 -0500 Message-ID: <00b801c09dde$f8cf2740$2dd260d1@arcamax.com> From: "Bryan White" To: "pgsql" References: <3A9822F2.FF9437C9@mondo-live.com> Subject: Re: Controlling Reuslts with Limit Date: Fri, 23 Feb 2001 16:24:14 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200102/368 X-Sequence-Number: 1567 > Hi, > I was reading through Bruce's on line . I found follwing bit unclear... > > "Notice that each query uses ORDER BY . Although this clause is not required, > LIMIT without ORDER BY returns random rows from the query, which would be > useless. " > > When I run a query several time I get the same results as given ... > I just want to know what exatly --"LIMIT without ORDER BY returns random rows > from the query" --means I don't think it is actually random. It just that the order is not defined and other events may change the order. I believe that without an ORDER BY or other clauses that cause an index to be used that the database tends to return rows in the order stored on disk. This order tends to be the order in which rows were added. My observation is this ordering is faily stable and it seems to survive a database reload. Just don't rely on it. There is a CLUSTER command to change the physical ordering.