Re: Performance of ORDER BY RANDOM to select random rows?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Victor Hooi <victorhooi(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance of ORDER BY RANDOM to select random rows?
Date: 2013-08-08 08:55:18
Message-ID: 20130808085517.GA26014@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 08, 2013 at 12:01:17PM +1000, Victor Hooi wrote:
> I'm just wondering if this is still the case?

Yes. Order by random() is and, most likely, will be slow. Not sure if
there is any engine that could make it fast.

> I just ran those benchmarks on my system (Postgres 9.2.4), and using ORDERY
> BY RANDOM did not seem substantially to generating random integers in
> Python and picking those out (and handling non-existent rows).

I think you accidentally a word.

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message AI Rumman 2013-08-08 13:23:49 setting high value for wal_keep_segments
Previous Message Alban Hertroys 2013-08-08 07:44:38 Re: How to prevent clear screen when query finish ?