Re: selecting random rows
От | Dennis Gearon |
---|---|
Тема | Re: selecting random rows |
Дата | |
Msg-id | 3F611469.5070606@fireserve.net обсуждение исходный текст |
Ответ на | selecting random rows (Joseph Shraibman <jks@selectacast.net>) |
Ответы |
Re: selecting random rows
|
Список | pgsql-general |
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 slowness in the IN() keyword. Others may comment at will, and polish this up? 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. > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if > your > joining column's datatypes do not match >
В списке pgsql-general по дате отправления: