Re: limitby without orderby

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Rohan Malhotra *EXTERN*" <yourbuddyrohan(at)gmail(dot)com>, "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: limitby without orderby
Date: 2011-09-22 14:42:50
Message-ID: D960CB61B694CF459DCFB4B0128514C2049FCE76@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rohan Malhotra wrote:
> 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 second query will not return the rows in a randomized order, but rather
in the order they are found. You should use the first query.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eric Ridge 2011-09-22 14:54:39 OS X 10.7, psql, and tab completion?
Previous Message Albe Laurenz 2011-09-22 14:37:18 Re: why VOLATILE attribute is required?