From: Jeff Herrin <jeff@alternateimage.com>
To: Aaron Bono <postgresql@aranya.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: consistent random order
Date: Wed, 29 Nov 2006 12:30:57 -0500 (EST)
Message-ID: <6801364.59051164821457152.JavaMail.root@srv161.carpathiahost.net> (raw)
In-Reply-To: <bf05e51c0611290923s2cfcd332l5ab20e74a606c858@mail.gmail.com>
I need it a little more random than that. In both these scenarios, the same items will always follow each other.
Jeff
----- Original Message -----
Why not create a random seed between 1 and the number of possibilities in your web application when a user first hits the site, 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 number? That way you get the first item chosen at random but the rest are sequential. If you want this somewhat random, create a "random" ordering field on the table and sort by that so the pages are not sorted by name 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 site, the "random" page picks up where it left off.
Just an idea...
--
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.comhttp://codeelixir.com
==================================================================
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jeff@alternateimage.com, postgresql@aranya.com
Subject: Re: consistent random order
In-Reply-To: <6801364.59051164821457152.JavaMail.root@srv161.carpathiahost.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox