From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: consistent random order
Date: Wed, 29 Nov 2006 18:27:42 +0100
Message-ID: <20061129172742.GA9005@KanotixBox> (raw)
In-Reply-To: <15697722.58781164818297562.JavaMail.root@srv161.carpathiahost.net>
References: <15697722.58781164818297562.JavaMail.root@srv161.carpathiahost.net>
Jeff Herrin <jeff@alternateimage.com> 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°
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: akretschmer@spamfence.net
Subject: Re: consistent random order
In-Reply-To: <20061129172742.GA9005@KanotixBox>
* 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