From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jelle Ouwerkerk <jelle(at)openface(dot)ca>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: random |
Date: | 2001-03-05 21:29:12 |
Message-ID: | 200103052129.QAA03712@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> Jelle Ouwerkerk <jelle(at)openface(dot)ca> writes:
> > Also, is there a way to randomize the order of a result set?
> >>
> >> There's always
> >> SELECT * FROM foo ORDER BY random();
>
> > However:
> > test=> select * from pg_class order by random();
> > does return some output. Is it random, and if so, how?
>
> Sure. The function is marked noncachable, so it gets evaluated
> afresh at each row --- but only once per row, as the sort step doesn't
> recompute any values. Should work just peachy, and it seems to do
> so in a couple quick tests.
But random returns a random value from 0-1, right? How does that work
in ORDER BY?
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-03-05 21:34:31 | Re: random |
Previous Message | Tom Lane | 2001-03-05 21:23:37 | Re: random |