Re: random

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(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:23:37
Message-ID: 20854.983827417@sss.pgh.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.

regards, tom lane

In response to

  • Re: random at 2001-03-05 21:04:35 from Bruce Momjian

Responses

  • Re: random at 2001-03-05 21:29:12 from Bruce Momjian

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2001-03-05 21:29:12 Re: random
Previous Message Stephan Szabo 2001-03-05 21:20:56 Re: random