Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 9CDC29FA1A1 for ; Wed, 29 Nov 2006 13:37:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 07395-10 for ; Wed, 29 Nov 2006 13:37:07 -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 D4AED9FA103 for ; Wed, 29 Nov 2006 13:37:25 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by ai.4ph.com (Postfix) with ESMTP id 39128230805F; Wed, 29 Nov 2006 12:31:25 -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 qPyUft4TzZFI; Wed, 29 Nov 2006 12:31:18 -0500 (EST) Received: from ai.4ph.com (ai.4ph.com [66.117.56.228]) by ai.4ph.com (Postfix) with ESMTP id 17A2A2308055; Wed, 29 Nov 2006 12:30:58 -0500 (EST) Message-ID: <6801364.59051164821457152.JavaMail.root@srv161.carpathiahost.net> Date: Wed, 29 Nov 2006 12:30:57 -0500 (EST) From: Jeff Herrin To: Aaron Bono Subject: Re: consistent random order Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1486_2485406.1164821457151" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.473 tagged_above=0 required=5 tests=AWL, BAYES_05, HTML_10_20, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200611/277 X-Sequence-Number: 26929 ------=_Part_1486_2485406.1164821457151 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I need it a little more random than that. In both these scenarios, the same= items will always follow each other.=20 Jeff=20 ----- Original Message -----=20 Why not create a random seed between 1 and the number of possibilities in y= our web application when a user first hits the site, store that in the sess= ion and then increment it by 1 (do a modulus to wrap the numbers back to 1)= and just select with an offset equal to this number?=C2=A0 That way you ge= t the first item chosen at random but the rest are sequential.=C2=A0 If you= want this somewhat random, create a "random" ordering field on the table a= nd sort by that so the pages are not sorted by name or id or whatever else = it may normally sort by.=20 You could then take it further and use cookies so the next time that person= comes to the site, the "random" page picks up where it left off.=20 Just an idea...=20 --=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20 =C2=A0=C2=A0 Aaron Bono=20 =C2=A0=C2=A0 Aranya Software Technologies, Inc.=20 =C2=A0=C2=A0 http://www.aranya.com=20 =C2=A0=C2=A0 http://codeelixir.com=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ------=_Part_1486_2485406.1164821457151 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable I need it a little more random than that. In both these scenari= os, the same items will always follow each other.

Jeff

-----= Original Message -----
Why not create a random seed between 1 and the n= umber of possibilities in your web application when a user first hits the s= ite, store that in the session and then increment it by 1 (do a modulus to = wrap the numbers back to 1) and just select with an offset equal to this nu= mber?  That way you get the first item chosen at random but the rest a= re sequential.  If you want this somewhat random, create a "random" or= dering field on the table and sort by that so the pages are not sorted by n= ame or id or whatever else it may normally sort by.

You could then = take it further and use cookies so the next time that person comes to the s= ite, the "random" page picks up where it left off.

Just an idea...
--
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
   Aaron Bono
   Aranya Software Technologies, = Inc.
   htt= p://www.aranya.com
   http://codeelixir.com
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D ------=_Part_1486_2485406.1164821457151--