Received: from candle.pha.pa.us (candle.navpoint.com [162.33.245.46]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f25LTRx43405 for ; Mon, 5 Mar 2001 16:29:27 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id QAA03712; Mon, 5 Mar 2001 16:29:12 -0500 (EST) From: Bruce Momjian Message-Id: <200103052129.QAA03712@candle.pha.pa.us> Subject: Re: random In-Reply-To: <20854.983827417@sss.pgh.pa.us> "from Tom Lane at Mar 5, 2001 04:23:37 pm" To: Tom Lane Date: Mon, 5 Mar 2001 16:29:12 -0500 (EST) CC: Jelle Ouwerkerk , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL77 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200103/66 X-Sequence-Number: 1711 > Bruce Momjian writes: > >> Jelle Ouwerkerk 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@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026