Re: [GENERAL] selecting random rows

2003-09-12 Thread Bruce Momjian
Joseph Shraibman wrote: > Is there a way to get random rows besides ORDER BY random()? The problem with ORDER > BY > random() is that is has to get all the rows from the table before the results are > returned. Yes, I think one person's idea was to assign a unique value to every row, then do:

Re: [GENERAL] selecting random rows

2003-09-12 Thread Dennis Gearon
If you have a nice small Primary key on the table, you can so something like this: SELECT field_list FROM table WHERE primary_key IN( SELECT primary_key, FROM table ORDER by RANDOM() LIMIT your_limit); This may not be the exact sequence, and there is some workarounds for some slo