| From: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
|---|---|
| To: | Rohan Malhotra <yourbuddyrohan(at)gmail(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: limitby without orderby |
| Date: | 2011-09-22 21:40:22 |
| Message-ID: | CAOR=d=305p=oBfAfco=5+1-K4agF1YwspLwpAoNYv+cKqHMj3w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Sep 22, 2011 at 5:32 AM, Rohan Malhotra
<yourbuddyrohan(at)gmail(dot)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...
| From | Date | Subject | |
|---|---|---|---|
| Next Message | John R Pierce | 2011-09-22 21:45:41 | Re: Replication between 64/32bit systems? |
| Previous Message | Josh Berkus | 2011-09-22 21:33:05 | PostgreSQL to Ingres migration |