From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Joseph Shraibman <jks(at)selectacast(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: selecting random rows |
Date: | 2003-09-12 00:26:56 |
Message-ID: | 200309120026.h8C0Qu513895@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Joseph Shraibman wrote:
> Is there a way to get random rows besides ORDER BY random()? The problem with ORDER BY
> random() is that is has to get all the rows from the table before the results are returned.
Yes, I think one person's idea was to assign a unique value to every
row, then do:
WHERE col > random()
ORDER BY col
LIMIT 1
or something like that.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Dennis Gearon | 2003-09-12 00:33:45 | Re: selecting random rows |
Previous Message | Bruce Momjian | 2003-09-12 00:26:06 | Re: NFS performance tuning |