limitby without orderby

From: Henry Drexler <alonup8tb(at)gmail(dot)com>
To: yourbuddyrohan(at)gmail(dot)com
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: limitby without orderby
Date: 2011-09-22 12:14:54
Message-ID: CAAtgU9RGhn9phG0jTmRFGq7+yO2rWedy+tbYojtrH+fb4gGC8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

*From*: Rohan Malhotra <yourbuddyrohan(at)gmail(dot)com>

select * from items order by random() 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.

--
Regards

To clarify, you are not looking for random then yes? as you want to
run select * from items order by random() limit 5; and not get
repeating values - as if you are using random you will at times get
repeating values.

You are wanting to get a gradually restrictive list(excluding those
results you have received previously)? So each time you run the query
you are guaranteed to get a new list of 5 rows?

Browse pgsql-general by date

  From Date Subject
Next Message Reuven M. Lerner 2011-09-22 12:26:38 Speed of lo_unlink vs. DELETE on BYTEA
Previous Message Albe Laurenz 2011-09-22 12:08:50 Re: looking for a faster way to do that