Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 1BDF29FB21D for ; Wed, 29 Nov 2006 13:39:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 59016-04 for ; Wed, 29 Nov 2006 13:39:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from ai.4ph.com (ai.4ph.com [66.117.56.228]) by postgresql.org (Postfix) with ESMTP id 6734D9FA103 for ; Wed, 29 Nov 2006 13:39:06 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by ai.4ph.com (Postfix) with ESMTP id DB885230805F; Wed, 29 Nov 2006 12:33:06 -0500 (EST) X-Virus-Scanned: amavisd-new at Received: from ai.4ph.com ([127.0.0.1]) by localhost (ai.4ph.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LrT-5erxBE-F; Wed, 29 Nov 2006 12:32:58 -0500 (EST) Received: from ai.4ph.com (ai.4ph.com [66.117.56.228]) by ai.4ph.com (Postfix) with ESMTP id B05FA230801C; Wed, 29 Nov 2006 12:32:57 -0500 (EST) Message-ID: <25133466.59111164821576601.JavaMail.root@srv161.carpathiahost.net> Date: Wed, 29 Nov 2006 12:32:56 -0500 (EST) From: Jeff Herrin To: Andreas Kretschmer Subject: Re: consistent random order Cc: pgsql-sql@postgresql.org In-Reply-To: <20061129172742.GA9005@KanotixBox> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/278 X-Sequence-Number: 26930 I don't think cursors are going to help in this case. The order by random()= is still going to give different result sets on different pages. Jeff ----- Original Message ----- From: Andreas Kretschmer To: pgsql-sql@postgresql.org Sent: Wednesday, November 29, 2006 12:27:42 PM GMT-0500 US/Eastern Subject: Re: [SQL] consistent random order Jeff Herrin schrieb: > I am returning results ordered randomly using 'order by random()'. My iss= ue has > to do with page numbers in our web application. When I hit the 2nd page a= nd > retrieve results with an offset, ordering by random() isn't really what I= want > since I will often receive results that were on the 1st page (they get re= - > randomized). >=20 > I'm looking for a way to order in a controled random order. Maybe a UDF. I think you are searching for CURSORs. 18:25 < akretschmer> ??cursor 18:25 < rtfm_please> For information about cursor 18:25 < rtfm_please> see http://www.postgresql.org/docs/current/static/plpg= sql-cursors.html 18:25 < rtfm_please> or http://www.postgresql.org/docs/current/static/sql-d= eclare.html With a CURSOR, you get one result-set and can walk through this result. Andreas --=20 Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082=C2=B0, E 13.5688= 9=C2=B0 ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate