From: | Jeff Herrin <jeff(at)alternateimage(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | consistent random order |
Date: | 2006-11-29 16:38:17 |
Message-ID: | 15697722.58781164818297562.JavaMail.root@srv161.carpathiahost.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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. Ideally I would need to do this:
ORDER BY myRandomUDF(1234)
or
ORDER BY myRandomUDF(2345)
Where the argument acts like a seed that always returns a consistent pseudo-random set. That way, when I get to the 2nd page, i know i'm getting the dataset back in the same order that I had on page 1, and the offset works like normal. Is this even realistically possible?
Thanks,
Jeff Herrin
From | Date | Subject | |
---|---|---|---|
Next Message | James Robinson | 2006-11-29 17:08:12 | Subselects in CHECK clause ... |
Previous Message | Ragnar | 2006-11-28 09:28:18 | Re: UNICODE and PL/PGSQL |