On Thu, Sep 22, 2011 at 5:32 AM, Rohan Malhotra
<yourbuddyro...@gmail.com> wrote:
> Hi Gurus,
> What is difference between
> select * from items order by random() limit 5;
> and
> select * items limit 5;
> my basic requirement is to get random rows from a table, my where clause
> will make sure I won't get same rows in repeated execution of above queries.

The biggest problem with the order by random() limit 5 is the cost.
If there's 1,000 or so rows, no big deal, if there's 10,000,000 rows
it's gonna be slow...

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to