Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A402D9FA1A1 for ; Wed, 29 Nov 2006 13:27:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 44846-07 for ; Wed, 29 Nov 2006 13:27:16 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 9AC7A9FA103 for ; Wed, 29 Nov 2006 13:27:19 -0400 (AST) Received: from a-kretschmer.de (p54B38F6B.dip0.t-ipconnect.de [84.179.143.107]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id kATHQr6K004095 for ; Wed, 29 Nov 2006 18:26:59 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) (envelope-from ) id 1GpTDi-00057r-4j for pgsql-sql@postgresql.org; Wed, 29 Nov 2006 18:27:42 +0100 Date: Wed, 29 Nov 2006 18:27:42 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: consistent random order Message-ID: <20061129172742.GA9005@KanotixBox> References: <15697722.58781164818297562.JavaMail.root@srv161.carpathiahost.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <15697722.58781164818297562.JavaMail.root@srv161.carpathiahost.net> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/276 X-Sequence-Number: 26928 Jeff Herrin schrieb: > I am returning results ordered randomly using 'order by random()'. My issue has > to do with page numbers in our web application. When I hit the 2nd page and > 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). > > 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/plpgsql-cursors.html 18:25 < rtfm_please> or http://www.postgresql.org/docs/current/static/sql-declare.html With a CURSOR, you get one result-set and can walk through this result. Andreas -- 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°, E 13.56889°